Reorganize Copy and CopyLine actions

Make Copy return false if there is no selection, and change the default
binding for Ctrl-c from CopyLine|Copy to Copy|CopyLine accordingly,
to make the semantics more meaningful: copying selection always fails
if there is no selection.
This commit is contained in:
Dmytro Maluka
2024-06-09 01:53:45 +02:00
parent 2860efbe3a
commit 830768b715
4 changed files with 11 additions and 13 deletions

View File

@@ -1164,20 +1164,18 @@ func (h *BufPane) Redo() bool {
// Copy the selection to the system clipboard
func (h *BufPane) Copy() bool {
if h.Cursor.HasSelection() {
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.freshClip = true
InfoBar.Message("Copied selection")
if !h.Cursor.HasSelection() {
return false
}
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.freshClip = true
InfoBar.Message("Copied selection")
h.Relocate()
return true
}
// CopyLine copies the current line to the clipboard
func (h *BufPane) CopyLine() bool {
if h.Cursor.HasSelection() {
return false
}
origLoc := h.Cursor.Loc
origLastVisualX := h.Cursor.LastVisualX
h.Cursor.SelectLine()