Skip to content

Commit

Permalink
Make lastCutTime actually work
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmaluka committed Jun 9, 2024
1 parent 8bc6756 commit 52ed431
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/action/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1201,15 +1201,15 @@ 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)
} else {
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
Expand Down

0 comments on commit 52ed431

Please sign in to comment.