From 91992de3c09c2bd88a995bac6822e3c3678b08dc Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Mon, 16 Dec 2024 18:02:24 +0200 Subject: Fixed a bug when forward-pasting in normal mode where it'd have an extra blank line when pasting on a blank line when the register ends with \n --- internal/client/ui/viminput/viminput.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'internal/client') diff --git a/internal/client/ui/viminput/viminput.go b/internal/client/ui/viminput/viminput.go index 5934ed7..e4886a4 100644 --- a/internal/client/ui/viminput/viminput.go +++ b/internal/client/ui/viminput/viminput.go @@ -437,11 +437,18 @@ func (m *Model) handleNormalModeKeys(key tea.KeyMsg) { runeLines = append(runeLines, []rune(line)) } - m.lines = slices.Insert(m.lines, m.cursorLine+1, runeLines...) + if len(line) != 0 { + m.lines = slices.Insert(m.lines, m.cursorLine+1, runeLines...) + m.SetCursorLine(m.cursorLine + 1) + _, col := m.Motion("_") + m.SetCursorColumn(col) + } else { + m.lines[m.cursorLine] = runeLines[0] + m.lines = slices.Insert(m.lines, m.cursorLine+1, runeLines[1:]...) + _, col := m.Motion("_") + m.SetCursorColumn(col) + } - m.SetCursorLine(m.cursorLine + 1) - _, col := m.Motion("_") - m.SetCursorColumn(col) } else { var runeLines [][]rune for _, line := range lines { -- cgit v1.3.1