From e6825f0e084e662bd3a79bcec96c874308aa8332 Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sun, 9 Jun 2024 13:14:02 +0200 Subject: [PATCH] CutLine: make infobar message more useful Since CutLine may add lines to the clipboard instead of replacing the clipboard, improve its info message to show how many lines are in the clipboard in total, not just how many lines were added to it last time. --- internal/action/actions.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index b0a959ba..9e9cb8b8 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -1242,11 +1242,13 @@ func (h *BufPane) CutLine() bool { if nlines == 0 { return false } + totalLines := nlines if h.freshClip && time.Since(h.lastCutTime) < 10*time.Second { if clip, err := clipboard.Read(clipboard.ClipboardReg); err != nil { InfoBar.Error(err) } else { clipboard.WriteMulti(clip+string(h.Cursor.GetSelection()), clipboard.ClipboardReg, h.Cursor.Num, h.Buf.NumCursors()) + totalLines = strings.Count(clip, "\n") + nlines } } else { h.Copy() @@ -1256,8 +1258,8 @@ func (h *BufPane) CutLine() bool { h.Cursor.DeleteSelection() h.Cursor.ResetSelection() h.Cursor.StoreVisualX() - if nlines > 1 { - InfoBar.Message(fmt.Sprintf("Cut %d lines", nlines)) + if totalLines > 1 { + InfoBar.Message(fmt.Sprintf("Cut %d lines", totalLines)) } else { InfoBar.Message("Cut line") }