summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Jump.zig2
-rw-r--r--core/Pick.zig41
-rw-r--r--core/TagState.zig5
-rw-r--r--core/replica.zig3
4 files changed, 21 insertions, 30 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;