summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-12-16 18:02:24 +0200
committerKyren223 <Kyren223@proton.me>2024-12-16 18:02:24 +0200
commit91992de3c09c2bd88a995bac6822e3c3678b08dc (patch)
tree6662cd29b7bc51707c68994b9db4cae77d5ce1cc /internal
parentc990c2690666b751db0ab0d20ad217bb000d9fc2 (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')
-rw-r--r--internal/client/ui/viminput/viminput.go15
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 {