diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/edit.zig | 3 | ||||
| -rw-r--r-- | src/mouse.zig | 6 | ||||
| -rw-r--r-- | src/pardes.zig | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/edit.zig b/src/edit.zig index 8d3a746e..1e480785 100644 --- a/src/edit.zig +++ b/src/edit.zig @@ -2012,7 +2012,8 @@ pub fn pushUndo(p: *Pardes, t: *Text) void { // one keystroke, one undo step — even when it edited at ten cursors. if (p.multi_on and !p.multi_first) return; switch (t.what) { - .body => {}, + // A B1 chord took its one undo point when it began (mouse.zig). + .body => if (p.chord_hold) return, .tag, .column, .workspace => return t.remember(p.gpa, if (t.own) |own| .{ .text = own } else null), // a prompt's answer is typed once and gone; it keeps no history .input => return, diff --git a/src/mouse.zig b/src/mouse.zig index ac3e206b..61bd30e0 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -790,6 +790,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void { // stream; only the button which began this gesture may end it. if (p.drag.button() != button) return; defer p.drag = .none; + defer p.chord_hold = false; switch (p.drag) { .border_v => |d| { const c = d.left_col; @@ -1027,6 +1028,11 @@ fn chordCutPaste(p: *Pardes, cut: bool) void { } if (!s.chorded) { s.chorded = true; + // Everything done while B1 stays down is one undo step, as acme + // marks the file once per B1 hold (text.c:881 textselect, `state` + // and its one filemark): B1-B2 then B1-B3 is a copy. + edit.pushUndo(p, &pane.body); + p.chord_hold = true; const sl = pane.sel[sel_slot]; pane.sel[sel_slot].state = .none; const pfx: i32 = if (pane.file != null) panes.File.gutterWidth(pane) else 0; diff --git a/src/pardes.zig b/src/pardes.zig index 60d0f51b..20d46dc3 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4118,6 +4118,8 @@ pub const Pardes = struct { /// The last plain B1 click, for acme's double-click (text.c:881, /// textselect: a second click at the same point within 500 ms). last_click: ?struct { id: usize, on_tag: bool, row: i32, col: i32, ms: i64 } = null, + /// A B1 chord's edits share the undo point it took (mouse.zig). + chord_hold: bool = false, look_hover_wait: ?look.LookHoverWait = null, look_hover_preview: ?look.LookHoverPreview = null, pdf_hover_preview: if (pdf_enabled) ?look.PdfWordPreview else void = if (pdf_enabled) null else {}, |
