Skip to content

Commit

Permalink
Fix regression in CopyLine, CutLine, DeleteLine for last line
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
dmaluka committed Oct 24, 2024
1 parent b3227d6 commit cca72eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/action/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cca72eb

Please sign in to comment.