diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-12-16 18:02:24 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-12-16 18:02:24 +0200 |
| commit | 91992de3c09c2bd88a995bac6822e3c3678b08dc (patch) | |
| tree | 6662cd29b7bc51707c68994b9db4cae77d5ce1cc /internal/client/ui/viminput | |
| parent | c990c2690666b751db0ab0d20ad217bb000d9fc2 (diff) | |
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
Diffstat (limited to 'internal/client/ui/viminput')
| -rw-r--r-- | internal/client/ui/viminput/viminput.go | 15 |
1 files changed, 11 insertions, 4 deletions
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 { |
