From 52ed4315ff521f27b9042f8dfa292cb618370f51 Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sun, 9 Jun 2024 12:07:07 +0200 Subject: [PATCH] Make lastCutTime actually work The CutLine action has a feature: if we execute it multiple times to cut multiple lines, new cut lines are added to the previously cut lines in the clipboard instead of replacing the clipboard, unless those previously cut lines have been already pasted or the last cut was more than 10 seconds ago. This last bit doesn't really work: newly cut lines are appended to the clipboard regardless of when was the last cut. So fix it. --- internal/action/actions.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index 5cb177ea..28337d72 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -1201,7 +1201,7 @@ func (h *BufPane) CutLine() bool { if !h.Cursor.HasSelection() { return false } - if h.freshClip { + if h.freshClip && time.Since(h.lastCutTime) < 10*time.Second { if h.Cursor.HasSelection() { if clip, err := clipboard.Read(clipboard.ClipboardReg); err != nil { InfoBar.Error(err) @@ -1209,7 +1209,7 @@ func (h *BufPane) CutLine() bool { clipboard.WriteMulti(clip+string(h.Cursor.GetSelection()), clipboard.ClipboardReg, h.Cursor.Num, h.Buf.NumCursors()) } } - } else if time.Since(h.lastCutTime)/time.Second > 10*time.Second || !h.freshClip { + } else { h.Copy() } h.freshClip = true