From bb1d1d275df7efa3a2a017daa48cb21291fdd03d Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 26 May 2025 07:53:43 -0400 Subject: [PATCH] fix(textarea): suppress blink messages when real cursor is active --- textarea/textarea.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/textarea/textarea.go b/textarea/textarea.go index 285c394..f56bc83 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -1196,13 +1196,18 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { m.viewport = &vp cmds = append(cmds, cmd) - newRow, newCol := m.cursorLineNumber(), m.col - m.virtualCursor, cmd = m.virtualCursor.Update(msg) - if (newRow != oldRow || newCol != oldCol) && m.virtualCursor.Mode() == cursor.CursorBlink { - m.virtualCursor.Blink = false - cmd = m.virtualCursor.BlinkCmd() + if m.useVirtualCursor { + m.virtualCursor, cmd = m.virtualCursor.Update(msg) + + // If the cursor has moved, reset the blink state. This is a small UX + // nuance that makes cursor movement obvious and feel snappy. + newRow, newCol := m.cursorLineNumber(), m.col + if (newRow != oldRow || newCol != oldCol) && m.virtualCursor.Mode() == cursor.CursorBlink { + m.virtualCursor.Blink = false + cmd = m.virtualCursor.BlinkCmd() + } + cmds = append(cmds, cmd) } - cmds = append(cmds, cmd) m.repositionView()