From 1ead9ce4fd44bde1ba93ebce01991bd7d932d97f Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Thu, 24 Oct 2024 18:01:45 +0200 Subject: [PATCH] Fix regression in CopyLine, CutLine, DeleteLine for last line (#3519) Fix regression introduced in commit fdacb289624a ("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). --- internal/action/actions.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index 2c7157c4..82ca983f 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -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