Fix regression in CopyLine, CutLine, DeleteLine for last line (#3519)

Fix regression introduced in commit fdacb28962 ("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).
This commit is contained in:
Dmytro Maluka 2024-10-24 18:01:45 +02:00 committed by GitHub
parent b3227d6049
commit 1ead9ce4fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1300,7 +1300,13 @@ func (h *BufPane) selectLines() int {
} else {
h.Cursor.SelectLine()
}
return h.Cursor.CurSelection[1].Y - h.Cursor.CurSelection[0].Y
nlines := h.Cursor.CurSelection[1].Y - h.Cursor.CurSelection[0].Y
if nlines == 0 && h.Cursor.HasSelection() {
// selected last line and it is not empty
nlines++
}
return nlines
}
// Copy the selection to the system clipboard