diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 21:45:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 23:24:00 -0300 |
| commit | 24dc19130fd6a063bb7e86fa21a02d7af4c3b163 (patch) | |
| tree | 761d6a1b439f5ea31f3679c8b4f2874e0acfbeb7 /core/Command.zig | |
| parent | 8d2a064eb69a1f888c435c3a0e03468b59abbb0d (diff) | |
| download | pardes-24dc19130fd6a063bb7e86fa21a02d7af4c3b163.tar.gz pardes-24dc19130fd6a063bb7e86fa21a02d7af4c3b163.zip | |
Root, and the explicit root keys SPC f F, SPC f G and SPC :: Find, Grep and the `:` line run at the project's root, the nearest directory at or above the asking pane's holding a `.jj` or a `.git` (Pick.workTree, kept by zxsqtpol for this), the pane's own when none does, while SPC f f, SPC f g and `:` keep acme's directory (the user's ruling of 2026-11-26: "maybe some commands SHOULD run on the project root for convenience", explicit twins, nothing implicit); WHY A WORD: a leader leaf names a builtin (config.leader_path, leader_args) and `:` is a normal-mode role, so the three keys need one word that reaches the root: `Root <line>` runs the line as Exec does with the step's flag Pardes.exec_root set, bare (SPC :) it opens the `:` line marked to run there, and a script's `Root make` or `Root Grep x` falls out of it at a ctl for free; THE CHANGE: builtins.Root; Pardes.exec_root, a step's own (replica `.local`, root.zig's kept_out) like exec_column; execDir reads the root under it (a command pane's directory, Term's, and Query.create's, which now calls execDir in place of its copy of it); executeFrom sends Root's line to a command pane even from a shell at its prompt, and runCommand reuses only a finished command pane at the root for it (not the asking one); Pick.root: a picker Root asked lists from the root, its head `␣ f Find root`, `Grep root`, its list word `Find root …`, Exec on that word running at the root again, a Grep's leading directory read from the root (grepScope, unchanged); Command.root: SPC :'s line, its head `: root`, `= Root make` as its plain word, its Enter and its `:open ` run as Root; config: Root's leader path `:`, leader_args fF and fG run `Root Find` and `Root Grep`, which-key labels `Find root` and `Grep root` (bindings.zig); replica's may_wait gets back a kind row, `Root *` (the root's stat on the session's disk), walked as `Root Find` (walk_samples: bare Root, the `:` line, asks the disk nothing); docs: Root's own doc (the Help index row `SPC : Root`, builtins-tui.json from `zig build builtins-json`, the same line put in builtins-gui.json), the cheatsheet's leader list (three short rows), guide.typ's Find and Grep rows and its where-commands-run table; RUN (TEST FIRST): behaviour/find_grep.zig (the reference's Find and Grep chapter, new): a `.jj` project, `x.txt` two directories below it: SPC f f lists `x.txt` alone and no `Find root`, SPC f F `␣ f Find root` with `a/b/x.txt` and `top.txt` (`.jj` passed over); SPC f G `needle` `␣ f Grep root needle` with `a/b/x.txt:1 needle below` and `top.txt:1 … needle at the top`, `a needle` the first alone (a/ is the root's); look_and_exec.zig: `:pwd` makes a command pane named `<root>/a/b`, SPC : shows `: root` and its `pwd` a second command pane named `<root>` (a `.git` project), each body `% pwd`; the three fail on zxsqtpol 8d2a064eb69a (`not on the screen: ␣ f Find root`, `… ␣ f Grep root needle`, `… : root`), pass now; test/session.zig gains `advance`, the host's clock moved on, so a typed Grep's 80 ms pause comes due in a T1 test; REAL CHECK (a private detached session of this Debug build over 9P, CA's demo copied with a `.jj` at its top): from src/torque/types.cc SPC f f types.cc types.h, SPC f F `Find root` Makefile compile_commands.json src/torque/types.cc … 1/5, SPC f G ToString `Grep root` three hits from the root, `src ToString` narrowed, `:pwd` printed …/demo/src/torque, SPC : `: root`, `: root make = Root make`, its pwd printed …/demo, its make ran `clang++ … src/torque/types.cc` at the root (exit 2, the demo's error) and SPC e from types.cc walked to types.cc:7:11, `SPC :open Make` opened `Find root Make`; GOLDENS (process-test --update, read): leader.golden spc and unmapped (`: Root` after `/ All` in SPC's level), find.golden group (`F Find root`, `G Grep root` in SPC f's), nothing else moved; NO hot path (a stat per directory up to the root once per Root run; a flag and five bytes in the head); the dump and the digest gain two bools (Pick.root, Command.root): the 40,000-seed dump fuzz (40,000 + 40,000 join seeds, 1,779 image seeds) 11/11, core/fuzz.zig restored byte for byte; GATES: Debug core-test 1172/1349 (177 skipped), shell-test 1390/1393 (3 skipped; the walk with Root's row), addons 8/8, term-test 17/17, kitty-test 45/45, process-test 0 of 149 failed (3 skipped), pane-test 184/185, behaviour-test 293/293 and --replay 293/293 (+3), consumer-test, the soak twice (rtt 30/80/207: diverged 0, unequal 0, quiet checks 617/0 485/0 568/0 and 499/0 387/0 553/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak), daemon.py plain x3, games, window-clients, clients x5, relink, launch, pair, gui, client-motion rc 0, far rc 1 (`no link of the far client ended under the flood`, as on the base), client-resize-real skipped (no compositor), the macOS x86_64 and arm64 and FreeBSD cross-builds; ReleaseSafe: the build (0 invalid options), the soak (diverged 0, unequal 0, quiet checks 514/0 381/0 543/0, unlisted stops 0), process-test 1 of 149 failed (root-ctl Restore, as on the base), upgrade from the installed ab9fa40a7bbb, upgrade-gui, upgrade-self (65 s) and upgrade-back (40 s) each nothing left behind, launch, clients x3, far, gui, client-motion, client-resize-real, client-idle, pair, plain x3 rc 0; load 1.2 to 3.6
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Command.zig')
| -rw-r--r-- | core/Command.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/core/Command.zig b/core/Command.zig index bb42bbbd..ce4dd132 100644 --- a/core/Command.zig +++ b/core/Command.zig @@ -19,7 +19,9 @@ //! pipes typed last. Enter runs the line as B2 runs a word: a command as //! its pardes word (`:theme`'s the theme the window wears), anything else //! Exec'd. `:` on the empty field gives the keyboard to the tag's own text, -//! as `:` did before there was a field; `:` there gives it back. +//! as `:` did before there was a field; `:` there gives it back. `SPC :` +//! (Root bare) is its twin at the project's root: Enter runs the line as +//! Root, head `: root`. //! //! A view's own, as its prompt is (TagState.prompt.command): which rows //! the hits (TagState.hits) are of, and where in the field Tab writes. @@ -69,6 +71,9 @@ from: u16 = 0, /// Tab (or a click) wrote the current row into the field: the rows are /// the line's from before it, which Tab steps on through. completed: bool = false, +/// `SPC :` (Root bare): the line runs at the project's root, its head +/// `: root`. +root: bool = false, /// A command typed after `:`, its short name, what it takes, and what it /// does: the pardes word it is. @@ -97,10 +102,12 @@ const row_max = 96; /// A doc's rows, the fewest the names' band has. const doc_rows = 4; -/// `:` in pane `pane`'s body: the field empty in its tag, every row. -pub fn open(p: *Pardes, pane: *Pane) void { +/// `:` in pane `pane`'s body: the field empty in its tag, every row; its +/// line run by Root, at the project's root, when `root`. +pub fn open(p: *Pardes, pane: *Pane, root: bool) void { Prompt.open(p, pane, .command); if (p.view().tag_state.kind != .prompt) return; + p.view().tag_state.prompt.command.root = root; filter(p, pane); } @@ -166,8 +173,9 @@ pub fn filter(p: *Pardes, pane: *Pane) void { var buf: [Field.max + 8]u8 = undefined; const word = std.fmt.bufPrint(&buf, "Find {s}", .{arg}) catch return; const id = TagState.hostOf(p) orelse return; + const root = c.root; TagState.toRest(p); - return exec.runBuiltin(p, config.exec_cmd, id, "", word); + return exec.runBuiltin(p, if (root) .Root else config.exec_cmd, id, "", word); } c.rows = typed[i].rows; c.from = @intCast(l.name.len + 1); @@ -508,13 +516,14 @@ fn run(p: *Pardes, id: usize, pane: *Pane) void { // What it runs, read while the rows are there (the theme worn). var buf: [Field.max + 16]u8 = undefined; const r = plan(p, line, &buf); + const root = s.prompt.command.root; TagState.toRest(p); if (std.mem.trim(u8, line, " ").len == 0) return; p.prompt_history.command.add(line); p.registers.put(p.gpa, ':', line, 0, 1, true) catch |err| return p.reportError(.at(id), "command", err); if (r.said) |why| return p.setMessage(.at(id), why); switch (r.verb) { - .exec => exec.runBuiltin(p, config.exec_cmd, id, "", r.word), + .exec => exec.runBuiltin(p, if (root) .Root else config.exec_cmd, id, "", r.word), .look => exec.runBuiltin(p, config.look_cmd, id, "", r.word), .pipe => { const f = pane.file orelse return p.setMessage(.at(id), "only a file's text is piped"); @@ -537,6 +546,7 @@ pub fn plainWord(p: *Pardes, w: *std.Io.Writer, line: []const u8) ?[]const u8 { .look => w.writeAll(r.word) catch return null, .pipe => w.print("Edit |{s}", .{r.word}) catch return null, } + if (r.verb == .exec and p.view().tag_state.prompt.command.root) return "Root"; return if (r.verb == .look) "Look" else "Exec"; } |
