From 9dba9742f4f2071fd85c67c3a7fe311b7f37617c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 17:50:26 -0300 Subject: Enter and Tab on a tag word tell an event reader as a click on it does, at its place in the tag; only a look takes a diff line's address, an exec there takes the word (follows vpmzwuzk) Co-Authored-By: Claude Opus 5.5 --- src/pardes.zig | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 674128a1..425a0993 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -6296,12 +6296,13 @@ pub const Pardes = struct { const range = t.primaryRange(shown, 0); const lo = @min(range.anchor, range.head); const hi = @max(range.anchor, range.head); - const txt = if ((t.vsel.active and t.vsel.explicit) or t.msel.active) - shown[lo..hi] + const span: [2]usize = if ((t.vsel.active and t.vsel.explicit) or t.msel.active) + .{ lo, hi } else word: { const b = config.wordBounds(shown, modal.selectionCursor(shown, range)); - break :word shown[b.lo..b.hi]; + break :word .{ b.lo, b.hi }; }; + const txt = shown[span[0]..span[1]]; // A column tag's command acts on that column, empty or not. p.exec_column = if (header != null) p.header_column else null; defer p.exec_column = null; @@ -6310,7 +6311,12 @@ pub const Pardes = struct { // Out of the tag or header FIRST: Del frees the pane, Kill // and Restore the whole session. if (header != null) tagline.exitHeader(p) else pane.focus = .body; - if (txt.len > 0) exec.runBuiltin(p, cmd, p.active, "", txt); + if (txt.len == 0) return; + // A pane's tag word: an event reader hears it as a click on + // it, at its place in the tag (flatSurface is the tag's text). + if (header == null and t.what == .tag and + mouse.reportRange(p, p.active, cmd, txt, true, .{ .q0 = @intCast(span[0]), .q1 = @intCast(span[1]) }, null)) return; + exec.runBuiltin(p, cmd, p.active, "", txt); return; } edit.pinPaneCursor(p, &pane.body); @@ -6330,7 +6336,7 @@ pub const Pardes = struct { // The cursor's word as a click there takes it: one expansion // (exec.operandAt), a diff line's address and all, and an // event reader told as a click tells it. - const operand = exec.operandAt(p, pane, look.cursorWordSel(p, pane), false); + const operand = exec.operandAt(p, pane, look.cursorWordSel(p, pane), false, cmd == config.look_cmd); mouse.dispatchPointerBuiltin(p, p.active, cmd, operand.text, .{ .on_tag = false, .operand = operand }); return; } -- cgit v1.3