mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-01 02:10:23 +09:00
Make Cut, Copy, CopyLine don't mess with CutLine's multi line cuts
Weird behavior is observed e.g. if we cut some lines with CutLine, then copy some selection with Copy, then cut some other lines with CutLine, and then paste. The pasted cliboard contains not just the lines that were cut at the last step, but also the selection that was copied before that. Fix that by resetting the CutLine's repeated line cuts whenever we copy anything to the clipboard via any other action (Cut, Copy or CopyLine).
This commit is contained in:
@@ -1188,7 +1188,7 @@ func (h *BufPane) Copy() bool {
|
||||
return false
|
||||
}
|
||||
h.Cursor.CopySelection(clipboard.ClipboardReg)
|
||||
h.freshClip = true
|
||||
h.freshClip = false
|
||||
InfoBar.Message("Copied selection")
|
||||
h.Relocate()
|
||||
return true
|
||||
@@ -1206,7 +1206,7 @@ func (h *BufPane) CopyLine() bool {
|
||||
return false
|
||||
}
|
||||
h.Cursor.CopySelection(clipboard.ClipboardReg)
|
||||
h.freshClip = true
|
||||
h.freshClip = false
|
||||
if nlines > 1 {
|
||||
InfoBar.Message(fmt.Sprintf("Copied %d lines", nlines))
|
||||
} else {
|
||||
@@ -1228,7 +1228,7 @@ func (h *BufPane) Cut() bool {
|
||||
h.Cursor.CopySelection(clipboard.ClipboardReg)
|
||||
h.Cursor.DeleteSelection()
|
||||
h.Cursor.ResetSelection()
|
||||
h.freshClip = true
|
||||
h.freshClip = false
|
||||
InfoBar.Message("Cut selection")
|
||||
|
||||
h.Relocate()
|
||||
@@ -1251,7 +1251,7 @@ func (h *BufPane) CutLine() bool {
|
||||
totalLines = strings.Count(clip, "\n") + nlines
|
||||
}
|
||||
} else {
|
||||
h.Copy()
|
||||
h.Cursor.CopySelection(clipboard.ClipboardReg)
|
||||
}
|
||||
h.freshClip = true
|
||||
h.lastCutTime = time.Now()
|
||||
|
||||
@@ -235,7 +235,8 @@ type BufPane struct {
|
||||
// It is used for clearing the clipboard to replace it with fresh cut lines.
|
||||
lastCutTime time.Time
|
||||
|
||||
// freshClip returns true if the clipboard has never been pasted.
|
||||
// freshClip returns true if one or more lines have been cut to the clipboard
|
||||
// and have never been pasted yet.
|
||||
freshClip bool
|
||||
|
||||
// Was the last mouse event actually a double click?
|
||||
|
||||
Reference in New Issue
Block a user