diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 19:48:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 20:06:45 -0300 |
| commit | 8d2a064eb69a1f888c435c3a0e03468b59abbb0d (patch) | |
| tree | b9a62ca4b5653864d03c1f648e72d1667b40c118 | |
| parent | a88ea865f116469689c62454facde811bdb37ce6 (diff) | |
| download | pardes-8d2a064eb69a1f888c435c3a0e03468b59abbb0d.tar.gz pardes-8d2a064eb69a1f888c435c3a0e03468b59abbb0d.zip | |
Pick: Find and Grep search from the asking pane's directory again, as a command runs in its window's directory in acme, taking back W8's work-tree root (rqouyxqp 89f51118eb24): the user's ruling of 2026-11-26 ("File folder, i didn't like the other rules btw that changed acme semantic for this"); the leading directory that narrows a Grep (SPEC §5.1, "scoped to a directory if the query starts with one") is kept, read against the pane's directory (`sub needle` from the top of a tree searches sub/); THE CHANGE: Pick.open sets every source's directory to the asking pane's (Pardes.paneDir), as before W8; Pick.workTree, no longer called, is kept for the explicit root keys the user chose next (the coordinator's item 5: SPC f F, SPC f G, a `:` twin); grepScope's and take's words say the picker's directory, not the root; replica.zig's may_wait loses W8's `Find *` and `Grep *` rows (the root's stat; a Grep's leading directory still stats, but shell-test's far-client walk, replica.zig's may_wait check, calls the Grep row stale: no walked word stops there, as before W8); the `.git` the tests made "a work tree of its own: Find searches it, not the one the test runs in" goes (Pick.testFile, Jump.zig, TagState.walkedReader, replica.zig's plain-kind test, behaviour/addons.zig x4, addons_pdf.zig, other_files.zig, language_servers.zig): Find and Grep there list the test's own directory again; the docs (guide.typ's Find and Grep rows, builtins-*.json, the Help index) said "below this pane's directory" all along: no text to bring back; no dump, digest, frame or hot path touched (a picker's open: a stat per directory up to / fewer); RUN (TEST FIRST): Pick.zig's W8 test re-pinned, "Find and Grep search from the asking pane's directory ...": a tree with `.git` at its top, Find from src/deep/x.txt lists src/deep alone (one row, its directory the pane's), from the top three rows and `sub/name` one, Grep `needle` two hits and `sub needle` one, `sub/name.txt:1 needle one`, its place the top's sub/name.txt: fails on yuwytntu a88ea865f116 at Pick.zig:3768 (the directory the root), passes now; GOLDENS: process-test's find (test/snapshots/find.golden) re-recorded with --update: from sub/ZQMARK-beta.txt `SPC f f` lists sub/'s files, not the root's five, so the band is two rows shorter in its three picker snaps (`bod`, cancel, topbar), nothing else moved; GATES (Debug tui): core-test 1165/1342 (177 skipped; the importer's 7 cached), process-test find (PASS after --update; before it the GoldenMismatch above), behaviour-test 290/290 (its T1 runner 800 clean quits), shell-test 1390/1393 (3 skipped; the base's 1388/1391 and this line's two new tests); load 1.3 to 3.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
| -rw-r--r-- | core/Jump.zig | 2 | ||||
| -rw-r--r-- | core/Pick.zig | 41 | ||||
| -rw-r--r-- | core/TagState.zig | 5 | ||||
| -rw-r--r-- | core/replica.zig | 3 | ||||
| -rw-r--r-- | test/behaviour/addons.zig | 8 | ||||
| -rw-r--r-- | test/behaviour/addons_pdf.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/language_servers.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/other_files.zig | 2 | ||||
| -rw-r--r-- | test/snapshots/find.golden | 6 |
9 files changed, 21 insertions, 50 deletions
diff --git a/core/Jump.zig b/core/Jump.zig index 143aa9b5..3632a039 100644 --- a/core/Jump.zig +++ b/core/Jump.zig @@ -472,8 +472,6 @@ test "Ctrl-o pops the walk one word at a time (UX L'1): after SPC f f words, Ent defer p.deinit(); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); var text: [60 * 16]u8 = undefined; var w: std.Io.Writer = .fixed(&text); for (1..61) |n| try w.print("{s} {d}\n", .{ if (n % 12 == 4) "in_word" else "line", n }); diff --git a/core/Pick.zig b/core/Pick.zig index 398354b5..5499809a 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -255,8 +255,7 @@ pub fn open(p: *Pardes, from: usize, source: Source, word: []const u8, query: [] const pk = make(p, source) catch |err| return p.reportError(.at(from), "pick", err); pk.word.set(if (word.len > 0) word else words.get(source).word); pk.keys.set(words.get(source).keys); - // Find and Grep from the work tree's root (W8), as other finders search. - pk.dir.set(if (source == .find or source == .grep) workTree(p, Pardes.paneDir(asker)) else Pardes.paneDir(asker)); + pk.dir.set(Pardes.paneDir(asker)); pk.rows = p.gpa.dupe(u8, rows) catch |err| return p.reportError(.at(from), "pick", err); pk.cap = p.view().rects[from].h * 2 / 5; hostIn(p, pk, from) catch |err| return p.reportError(.at(from), "pick", err); @@ -269,8 +268,7 @@ pub fn open(p: *Pardes, from: usize, source: Source, word: []const u8, query: [] /// The work tree `dir` is in: the nearest directory at or above it that /// holds a `.jj` or a `.git` (a git worktree's is a file); `dir` itself -/// when none does. Find and Grep search from it, their rows' paths -/// relative to it, wherever in the tree the asking pane is. +/// when none does. fn workTree(p: *Pardes, dir: []const u8) []const u8 { var d = dir; while (true) { @@ -284,9 +282,9 @@ fn workTree(p: *Pardes, dir: []const u8) []const u8 { } /// Where a Grep's query `q` searches and for what (SPEC §5.1): a leading -/// directory, the root's or absolute, then a blank, narrows it to that +/// directory, the picker's or absolute, then a blank, narrows it to that /// directory (`src/torque Macro`), the rest the pattern; else all of it -/// from the root. The directory joined in `buf`. +/// from the picker's. The directory joined in `buf`. fn grepScope(p: *Pardes, pk: *const Pick, q: []const u8, buf: *[4096]u8) struct { dir: []const u8, pat: []const u8 } { const root = pk.dir.slice(); const sp = std.mem.indexOfScalar(u8, q, ' ') orelse return .{ .dir = root, .pat = q }; @@ -565,7 +563,7 @@ fn allPanes(p: *const Pardes, pk: *const Pick, out: *[pardes.MAX_PANES]usize) [] pub fn take(p: *Pardes, target: u32, kind: Stream.Kind, rows: []const u8) bool { const pk = byId(p, target) orelse return false; // A Grep narrowed to a directory (grepScope): its rows' paths from the - // root, as an unnarrowed one's are. + // picker's directory, as an unnarrowed one's are. var buf: [4096]u8 = undefined; const searched = p.stream.dir.items; const under = if (kind == .grep and !std.mem.eql(u8, searched, pk.dir.slice())) std.fmt.bufPrint(&buf, "{s}/", .{relative(searched, pk.dir.slice())}) catch "" else ""; @@ -2218,9 +2216,6 @@ pub fn execWord(p: *Pardes, txt: []const u8) bool { } fn testFile(p: *Pardes, tmp: *std.testing.TmpDir, name: []const u8, text: []const u8) ![]u8 { - // The directory a work tree of its own, as a project is: Find and Grep - // search it, not the tree the test runs in. - tmp.dir.createDir(std.testing.io, ".git", .default_dir) catch |err| if (err != error.PathAlreadyExists) return err; try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = text }); var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; const dir = base_buf[0..try tmp.dir.realPath(std.testing.io, &base_buf)]; @@ -3742,14 +3737,14 @@ test "Symbols: every row is ordinary text: no header rows, the cursor steps onto try std.testing.expect(std.mem.indexOf(u8, kept.?, "\ncounts.zig:2 t Counts = struct\n") != null); } -test "Find and Grep search the work tree (W8): from a pane deep in a repo Find lists the files from its root and `sub/name` narrows it, a leading directory narrows Grep, and outside a repo they search the pane's directory" { +test "Find and Grep search from the asking pane's directory, as a command runs in its window's (acme; the user's ruling of 2026-11-26 taking W8's work-tree root back): from deep in a repository Find lists that directory alone; from its top `sub/name` narrows Find, and a leading directory, the pane's directory's, narrows Grep" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); defer p.deinit(); p.settings.jumps = .walk; p.stream.engine = .walk; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - for ([_][]const u8{ "src/deep", "sub", "other" }) |d| try tmp.dir.createDirPath(std.testing.io, d); + for ([_][]const u8{ ".git", "src/deep", "sub", "other" }) |d| try tmp.dir.createDirPath(std.testing.io, d); const deep = try testFile(p, &tmp, "src/deep/x.txt", "deep\n"); defer p.gpa.free(deep); for ([_][2][]const u8{ .{ "sub/name.txt", "needle one\n" }, .{ "other/name.txt", "needle two\n" } }) |f| p.gpa.free(try testFile(p, &tmp, f[0], f[1])); @@ -3762,9 +3757,18 @@ test "Find and Grep search the work tree (W8): from a pane deep in a repo Find l var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); const a = frame.allocator(); - // Find from src/deep: the root's files, by their paths from it. + // Find from src/deep: its own file alone, the repository's root not asked. open(p, asker, .find, "", "", ""); var pk = live(p).?; + try std.testing.expectEqualStrings(std.Io.Dir.path.dirname(deep).?, pk.dir.slice()); + settle(p); + try std.testing.expectEqual(@as(usize, 1), count(p, pk)); + p.update(.{ .key = .{ .cp = Key.escape } }); + // From the top: every file, `sub/name` narrowing them to one. + p.gpa.free(p.panes[asker].?.file.?.path); + p.panes[asker].?.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ root, "top.txt" }); + open(p, asker, .find, "", "", ""); + pk = live(p).?; try std.testing.expectEqualStrings(root, pk.dir.slice()); settle(p); try std.testing.expectEqual(@as(usize, 3), count(p, pk)); @@ -3773,8 +3777,8 @@ test "Find and Grep search the work tree (W8): from a pane deep in a repo Find l try std.testing.expectEqual(@as(usize, 1), count(p, pk)); try std.testing.expectEqualStrings("sub/name.txt", (try rowAt(p, pk, a, 0)).text); p.update(.{ .key = .{ .cp = Key.escape } }); - // Grep: the whole tree, then `sub needle` in sub/ alone, its row's - // path from the root, landing on the file there. + // Grep: the whole directory, then `sub needle` in sub/ alone, its + // row's path from the pane's directory, landing on the file there. open(p, asker, .grep, "", "", ""); pk = live(p).?; for ("needle") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); @@ -3794,13 +3798,6 @@ test "Find and Grep search the work tree (W8): from a pane deep in a repo Find l try std.testing.expect(std.mem.startsWith(u8, row.text, "sub/name.txt:1 needle one")); try std.testing.expectEqualStrings(try std.Io.Dir.path.join(a, &.{ root, "sub/name.txt" }), row.target.place.path); p.update(.{ .key = .{ .cp = Key.escape } }); - // Outside a repo (`/`, the test text's directory, holds no .jj nor - // .git): the pane's directory, as before. - p.gpa.free(p.panes[asker].?.file.?.path); - p.panes[asker].?.file.?.path = try p.gpa.dupe(u8, "/held.txt"); - open(p, asker, .find, "", "", ""); - try std.testing.expectEqualStrings("/", live(p).?.dir.slice()); - p.update(.{ .key = .{ .cp = Key.escape } }); } test "a pane made for a picker has no rest: its tag is its owner's word alone, `‹@pN ›`, its body under it; the head hangs under the asking pane's tag (UX DESIGN M3, O1)" { diff --git a/core/TagState.zig b/core/TagState.zig index 468c7895..1ccc8156 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -1682,10 +1682,9 @@ fn gridRow(a: std.mem.Allocator, s: *const pardes.Surface, x: u16, y: u16, w: u1 return out.items; } -/// A reading pane in a work tree of its own that walked from `near.txt` to -/// `far.txt` (a place on its trail), the keyboard in its body. +/// A reading pane that walked from `near.txt` to `far.txt` (a place on its +/// trail), the keyboard in its body. fn walkedReader(p: *Pardes, tmp: *std.testing.TmpDir) !usize { - tmp.dir.createDir(std.testing.io, ".git", .default_dir) catch |err| if (err != error.PathAlreadyExists) return err; try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "near.txt", .data = "one\ntwo\nthree\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "far.txt", .data = "four\nfive\n" }); var buf: [std.Io.Dir.max_path_bytes]u8 = undefined; diff --git a/core/replica.zig b/core/replica.zig index 40bd757d..172ab6f3 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -7352,8 +7352,6 @@ const may_wait = [_]Wait{ .{ .what = "Save", .on = .any, .stop = "write_file", .why = "a save" }, // A program run, a shell opened or closed: the session's processes. .{ .what = "Exec *", .on = .any, .stop = "kind", .why = "a program run: its name asked of the disk first" }, - .{ .what = "Find *", .on = .any, .stop = "kind", .why = "the work tree it lists from, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the listing itself is the session's" }, - .{ .what = "Grep *", .on = .any, .stop = "kind", .why = "the work tree it searches, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the search itself is the session's" }, .{ .what = "Exec *", .on = .any, .stop = "tty_taken", .why = "a program run in a shell: whether one has it, the session's" }, .{ .what = "Exec *", .on = .command, .stop = "run a command", .why = "a line run again in its directory's finished command pane: its process and its emulator are the session's" }, .{ .what = "Term", .on = .any, .stop = "kind", .why = "a shell opened: its name asked of the disk first" }, @@ -9282,7 +9280,6 @@ test "a picker's preview opens and closes a plain kind's state in the pane it la const gpa = std.testing.allocator; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "paper.own", .data = "own" }); var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 88c477ea..46c8e012 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -381,8 +381,6 @@ fn dirOf(s: *Session, tmp: *std.testing.TmpDir) ![]const u8 { test "addons: a picker shows a file of an addon's kind through its kind in the pane it lands in, Esc puts that pane back as it was, and Enter lands as a Look does" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "seven.fake", .data = "1234567" }); var s = try Session.initFile(std.testing.allocator, "x\n"); @@ -425,8 +423,6 @@ test "addons: a picker shows a file of an addon's kind through its kind in the p test "addons: a picker's row of a file no kind takes and not text shows one line naming it, and the row before's file never stays in the body" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "other.txt", .data = "other text\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "seven.fake", .data = "1234567" }); @@ -468,8 +464,6 @@ test "addons: a picker's row of a file no kind takes and not text shows one line test "addons: moving the cursor over pictures in a picker draws only the one it rests on, and a draw of one passed by is dropped whenever it comes back" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); const png = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\xcf\xc0\x00\x00\x03\x01\x01\x00\xc9\xfe\x92\xef\x00\x00\x00\x00IEND\xaeB`\x82"; try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic1.png", .data = png }); @@ -507,8 +501,6 @@ test "addons: moving the cursor over pictures in a picker draws only the one it test "addons: Enter on a picture in a picker opens its kind's pane, never its bytes as text in the reading pane (the user's report)" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic.ppm", .data = "P6\n2 1\n255\n\x0d\x4d\xe7\x0d\x4d\xe7" }); var s = try Session.initFile(std.testing.allocator, "x\n"); diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig index c59b4a93..918d1842 100644 --- a/test/behaviour/addons_pdf.zig +++ b/test/behaviour/addons_pdf.zig @@ -307,8 +307,6 @@ test "addons: a PDF under a picker's cursor shows through the pdf addon in the p try s.loadPdf(); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); const pdf = try std.Io.Dir.cwd().readFileAlloc(std.testing.io, "docs/design.pdf", s.arena.allocator(), .limited(4 << 20)); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "paper.pdf", .data = pdf }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); diff --git a/test/behaviour/language_servers.zig b/test/behaviour/language_servers.zig index 7f1eef73..3b786ec4 100644 --- a/test/behaviour/language_servers.zig +++ b/test/behaviour/language_servers.zig @@ -386,8 +386,6 @@ test "language-servers: a file of a server's language opened in a pane starts th const io = std.testing.io; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(io, ".git", .default_dir); try tmp.dir.writeFile(io, .{ .sub_path = "a.zig", .data = "const a = 1;\n" }); try tmp.dir.writeFile(io, .{ .sub_path = "b.zig", .data = "const b = 2;\n" }); try tmp.dir.writeFile(io, .{ .sub_path = "c.py", .data = "c = 3\n" }); diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig index 95d4de6d..f1bd2ce0 100644 --- a/test/behaviour/other_files.zig +++ b/test/behaviour/other_files.zig @@ -25,8 +25,6 @@ test "other-files: kbdin types at the pane with the keyboard and mousein clicks, test "other-files: kbdin's keys are the user's: SPC f f opens Find's picker in the pane's tag where jumps walk, not the +Search a script's Find opens" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); - // A work tree of its own: Find searches it, not the one the test runs in. - try tmp.dir.createDir(std.testing.io, ".git", .default_dir); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "a\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = "b\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index aad12aca..493f9e11 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -79,8 +79,6 @@ |3: │ │ nothing matches |4: │ │ |5: │ │ -|6: │ │ -|7: │ │ |40: ⏎ lands here · its text is the preview · S-⏎ a new pane 1 message · SPC h m == snap cancel grid=120x41 cursor=7,2 |1: here.txt:1 › Find zqm 2/3 › /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Keep Del @@ -88,8 +86,6 @@ |3: |4: |5: -|6: -|7: |40: ✓ /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Find 1 message · SPC h m == snap topbar grid=120x41 cursor=14,2 |1: ^ here.txt:1 › Find zqm 2/3 › /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Keep Del @@ -97,6 +93,4 @@ |3: │ │ nothing matches |4: │ │ |5: │ │ -|6: │ │ -|7: │ │ |40: ⏎ lands here · its text is the preview · S-⏎ a new pane 1 message · SPC h m |
