Skip to content

Commit 1ead9ce

Browse files
authored
Fix regression in CopyLine, CutLine, DeleteLine for last line (zyedidia#3519)
Fix regression introduced in commit fdacb28 ("CopyLine, CutLine, DeleteLine: respect selection"): when CopyLine, CutLine or DeleteLine is done in the last line of the buffer and this line is not empty, this line gets selected but does not get copied/cut/deleted (and worse, it remains selected).
1 parent b3227d6 commit 1ead9ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/action/actions.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,13 @@ func (h *BufPane) selectLines() int {
13001300
} else {
13011301
h.Cursor.SelectLine()
13021302
}
1303-
return h.Cursor.CurSelection[1].Y - h.Cursor.CurSelection[0].Y
1303+
1304+
nlines := h.Cursor.CurSelection[1].Y - h.Cursor.CurSelection[0].Y
1305+
if nlines == 0 && h.Cursor.HasSelection() {
1306+
// selected last line and it is not empty
1307+
nlines++
1308+
}
1309+
return nlines
13041310
}
13051311

13061312
// Copy the selection to the system clipboard

0 commit comments

Comments
 (0)