summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 03:04:50 -0300
committerGabriel Schneider <[email protected]>2026-11-19 03:28:58 -0300
commit5df97028a994b7e8c1720fd2dd2c1d8d943a8300 (patch)
treeb84f636d75fb9ac35dc0d595f8fe10426093e79a
parent9cef1513bd4a9b0377b18f35b97aae141f9eb4e6 (diff)
downloadpardes-5df97028a994b7e8c1720fd2dd2c1d8d943a8300.tar.gz
pardes-5df97028a994b7e8c1720fd2dd2c1d8d943a8300.zip
look: n and N in a kind's pane are a motion that reads no disk (the reorganisation's 12a; the user's ruling P14: motions instant on a far client): they walked Look's candidates across every result and output pane, and a word or a row with no place of its own was look-able only if the disk said it named a file (look.wordSpan and lineSpan through look.resolve to fs.resolve's realpath: 33 of the soak's 43 `resolve` stops); lookWalk now takes `disk`, and the key in a kind's pane walks without it: only the places the rows already hold (a row's location, a command row's whole line), so it steps the kind's +Search, references, errors and the like at once and skips words that might name a file, while LookNext and LookPrev (words, a Look's walk, which may wait) and the walk to a kind's first hit keep asking the disk as before; a test at the end of core/replica.zig (a client's n in a plain kind's pane, a scratch whose words name files standing first in the walk, lands on the kind's +Search row at once, confirmed fast), shown failing on the change before (stopped 1); the semantics word did not move; tui core-test 831/973 (142 skipped), shell-test 1008/1011, pane-test 183/184, behaviour-test 275/275 and --replay 275/275, process-test 2 of 144 failed (lspcomplete, lspcompletemoved, the base's; headersweep and cmdexit flaked and passed again), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 quiet differ 0 at 30/80/207 ms, stopped 89/75/108 (the base 104/133/147), mispredicted 37/34/36 on a run whose inputs now differ from the base's (the probe's 2-seed run with every host entry classed each one, before and after: a join's view, a clock's millisecond, a file's second, never a host call's: reports/pardes-seam-a.md), gui unit-test 1606/1610 (its perf check's BaselineHarnessMismatch the base's), daemon.py plain, --far, --games, --window-clients pass; gate-w seam-a-3 against tree1: 77/77 frames byte-identical in Debug, perfab corpus2x +0.045%, perfops 97 counts within 0.1% (largest +0.0012%)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
-rw-r--r--core/builtins.zig4
-rw-r--r--core/look.zig19
-rw-r--r--core/normal.zig5
-rw-r--r--core/replica.zig54
4 files changed, 71 insertions, 11 deletions
diff --git a/core/builtins.zig b/core/builtins.zig
index b3e8d638..0d2e4c20 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -1641,7 +1641,7 @@ pub const Forward = struct {
pub const LookNext = struct {
pub const quiet = true;
pub fn run(c: Ctx) void {
- look.lookWalk(c.p, 1);
+ look.lookWalk(c.p, 1, true);
}
};
@@ -1649,7 +1649,7 @@ pub const LookNext = struct {
pub const LookPrev = struct {
pub const quiet = true;
pub fn run(c: Ctx) void {
- look.lookWalk(c.p, -1);
+ look.lookWalk(c.p, -1, true);
}
};
diff --git a/core/look.zig b/core/look.zig
index 6ff1da66..7ca8914f 100644
--- a/core/look.zig
+++ b/core/look.zig
@@ -335,7 +335,7 @@ fn lookFirstHit(p: *Pardes, id: usize) void {
const rp = p.panes[rid] orelse return;
if ((rp.file orelse return).content.len == 0) return;
p.view().active = rid;
- lookWalk(p, 1);
+ lookWalk(p, 1, true);
if (p.view().active != rid) return; // walked out of the list; leave it there
const txt = edit.currentSelText(p, rp) orelse return;
// spent, exactly as the look chord spends it (handleKey)
@@ -546,7 +546,7 @@ pub fn wordSpan(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, realbuf:
return .{ .start = 0, .end = word.len };
}
-fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usize) ?Pane.LookSpot {
+fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usize, disk: bool) ?Pane.LookSpot {
const lines = edit.paneCursorLines(p.editor(), &pane.body) catch return null;
const nrows: i32 = @intCast(lines.len);
if (nrows == 0) return null;
@@ -562,7 +562,8 @@ fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usiz
if (pane.file) |*f| if (!panes.Output.isWalkRow(f, @intCast(r), ln)) continue;
const on_start = r == start;
switch (grain) {
- .word => {
+ // Which words name a file is the disk's to say.
+ .word => if (disk) {
var best: ?Pane.LookSpot = null;
var i: usize = 0;
while (i < ln.len) {
@@ -577,7 +578,7 @@ fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usiz
if (delta > 0) break; // first one forward; keep the last one back
}
if (best) |b| return b;
- },
+ } else return null,
// one span per row, so there is nothing to keep and nothing to
// scan past: the row either offers it or it does not
.line, .whole => {
@@ -593,7 +594,7 @@ fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usiz
break :span @as(?Span, .{ .start = start_byte, .end = end });
}
};
- break :span lineSpan(p, ln, dir, &realbuf);
+ break :span if (disk) lineSpan(p, ln, dir, &realbuf) else null;
} orelse continue;
const col0: i32 = @intCast(sp.start);
if (lookPast(col0, from, on_start, delta))
@@ -610,7 +611,11 @@ fn commandPaneActive(p: *Pardes) bool {
return pane.command != null and pane.file == null and p.view().header == null;
}
-pub fn lookWalk(p: *Pardes, delta: i32) void {
+/// `disk`: a word or a row with no place of its own is look-able when it
+/// names a file, which the disk says (LookNext, a Look's walk, may wait);
+/// without, only the places the rows hold are (`n` in a kind's pane, a
+/// motion: what it reads is the core's).
+pub fn lookWalk(p: *Pardes, delta: i32, disk: bool) void {
var buf: [MAX_PANES]usize = undefined;
const order = lookWalkPanes(p, &buf);
if (order.len == 0) return;
@@ -628,7 +633,7 @@ pub fn lookWalk(p: *Pardes, delta: i32) void {
// `+ 2 * len` only so the backward subtraction stays unsigned
const idx = (if (delta > 0) at + k else at + 2 * order.len - k) % order.len;
const pane = p.panes[order[idx]] orelse continue;
- if (lookSpanIn(p, pane, from, delta, &budget)) |spot|
+ if (lookSpanIn(p, pane, from, delta, &budget, disk)) |spot|
return landLookSpot(p, order[idx], pane, spot);
if (budget == 0) return; // gave up mid-pane: stay put, stay reversible
from = lookEdge(delta);
diff --git a/core/normal.zig b/core/normal.zig
index fb392647..66df9608 100644
--- a/core/normal.zig
+++ b/core/normal.zig
@@ -1277,9 +1277,10 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error!
return panes.startPrompt(p, pane, &pane.body, .{ .search = config.search_marker }),
// In a file's text, n and N step its places while they answer for
// the register (Places.answersN); else helix's search of the register.
- // A kind's pane walks its `/`'s +Search (look.zig runSearch).
+ // A kind's pane walks its `/`'s +Search (look.zig runSearch): the
+ // places the rows hold, never the disk (a motion).
.search_next, .search_prev => if (t.what == .body and pane.addon != null)
- return look.lookWalk(p, if (a.role == .search_next) 1 else -1)
+ return look.lookWalk(p, if (a.role == .search_next) 1 else -1, false)
else if (t.what == .body and pane.file != null and pane.places.answersN(p, pane))
return pane.places.step(p, pane, a.role == .search_next, a.count, t.select)
else
diff --git a/core/replica.zig b/core/replica.zig
index 5ce8454e..fd691e04 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -5192,3 +5192,57 @@ test "a client's own Zerox and Del of a file pane are instant: what Recent keeps
try std.testing.expectEqual(@as(u32, 0), r.stats.mispredicted);
try std.testing.expect(a.core.recent.get(path) != null);
}
+
+/// A kind whose state is plain and that takes no keys: normal mode has
+/// them in its pane.
+const Still = struct {
+ const pa = pardes.Kind.c;
+ fn open(_: [*c]const u8, _: [*c]const u8, _: u64) callconv(.c) ?*anyopaque {
+ return pardes.Kind.api.alloc.?(4);
+ }
+ fn paint(_: ?*anyopaque, _: [*c]const pa.pa_window, _: [*c]pa.pa_paint) callconv(.c) void {}
+ const words = [_]pa.pa_word{std.mem.zeroInit(pa.pa_word, .{ .name = "Still", .opens = 1, .doc = "a pane that takes no keys" })};
+ const ops = std.mem.zeroInit(pardes.Kind.Ops, .{
+ .head = std.mem.zeroInit(pa.pa_head, .{ .size = @sizeOf(pa.pa_head), .abi = pardes.Kind.abi, .name = "still".* ++ @as([11]u8, @splat(0)), .version = 1, .exts = "", .flags = pa.PA_PLAIN, .words = &words, .nwords = 1 }),
+ .open = open,
+ .paint = paint,
+ });
+};
+
+test "a client's n in a kind's pane is a motion: it steps to the next place a result row holds at once, asking the disk nothing of words that might name files" {
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);
+ defer a.deinit();
+ var cwd: [std.Io.Dir.max_path_bytes]u8 = undefined;
+ const dir = std.mem.span(@as([*:0]u8, @ptrCast(std.c.getcwd(&cwd, cwd.len) orelse return error.NoCwd)));
+ var words: [64]pardes.Kind.LoadedWord = undefined;
+ const still = pardes.Kind.loadedOf(&Still.ops, "/x/still.so", @splat(7), &words);
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &still } });
+ // The kind's pane, its +Search (a place a row, as a kind's `/` leaves
+ // it), and a scratch whose words name files in the session's directory
+ // (as a command's output would).
+ _ = try a.local(.{ .command = "Still" });
+ const kid = a.core.view().active;
+ try pardes.panes.Output.fillResults(a.core, kid, dir, .search, "first", try a.core.gpa.dupe(u8, "build.zig:1:1 first\n"), null);
+ const rid = a.core.panes[kid].?.search_pane.?;
+ _ = try a.local(.{ .command = "New" });
+ for ("ibuild.zig mise.toml") |ch| _ = try a.local(.{ .key = .{ .cp = ch, .text = &[1]u8{ch} } });
+ _ = try a.local(.{ .key = .{ .cp = pardes.Key.escape } });
+ // The walk last stood in the scratch, at its start: its words first.
+ const scratch = a.core.panes[a.core.view().active].?;
+ scratch.body.cur_row = 0;
+ scratch.body.cur_col = 0;
+ a.core.look_walk_owner = scratch.serial;
+ a.core.view().active = kid;
+ const r = try joinedFresh(a);
+ defer r.deinit();
+ r.core().kinds.ops[r.core().kinds.byName("still").?] = &Still.ops;
+ const msg = try gpa.dupe(u8, try r.input(.{ .key = .{ .cp = 'n', .text = "n" } }));
+ defer gpa.free(msg);
+ try std.testing.expectEqual(@as(u32, 0), r.stats.stopped);
+ try std.testing.expectEqual(rid, r.core().view().active);
+ r.confirm(try a.take(msg));
+ r.settle();
+ try std.testing.expectEqual(@as(u32, 1), r.stats.fast);
+ try agrees(a, r);
+}