summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 4750fa0b..c6513392 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -3538,16 +3538,34 @@ pub const Pardes = struct {
.left => switch (m.kind) {
.press => {
// middle+left chord: a left press during a middle select-
- // drag captures the KEPT left selection as the execute's
- // argument; the middle drag keeps running to its release.
+ // drag captures a selection as the execute's argument; the
+ // middle drag keeps running to its release. The drag pane's
+ // own selection wins; a pane with none borrows from the
+ // OTHER panes (acme: the chord argument is whatever text is
+ // selected, in any window) — the ACTIVE pane first (making
+ // a selection focuses its pane, so it holds the most
+ // recently made one), then slot order. Per pane a kept left
+ // selection wins, else an explicit modal (v/x, n/N) one.
if (p.drag == .select and p.drag.select.button == .middle) {
- if (p.panes[p.drag.select.id]) |t| {
- const sl = t.sel[0];
- if (sl.state == .done) {
- if (p.chord_arg) |old| p.gpa.free(old);
- const txt = p.selectionText(t, sl) catch null;
- p.chord_arg = if (txt) |tx| (p.gpa.dupe(u8, tx) catch null) else null;
- }
+ const did = p.drag.select.id;
+ var txt: ?[]const u8 = null;
+ var k: usize = 0;
+ while (txt == null and k < p.panes.len + 2) : (k += 1) {
+ const i = switch (k) {
+ 0 => did,
+ 1 => p.active,
+ else => k - 2,
+ };
+ if (k > 0 and (i == did or (k > 1 and i == p.active))) continue;
+ const t = p.panes[i] orelse continue;
+ if (t.sel[0].state == .done)
+ txt = p.selectionText(t, t.sel[0]) catch null
+ else if ((t.vsel.active and t.vsel.explicit) or t.msel.active)
+ txt = p.currentSelText(t);
+ }
+ if (txt) |tx| {
+ if (p.chord_arg) |old| p.gpa.free(old);
+ p.chord_arg = p.gpa.dupe(u8, tx) catch null;
}
return;
}