diff options
Diffstat (limited to 'core/builtins.zig')
| -rw-r--r-- | core/builtins.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/builtins.zig b/core/builtins.zig index 62e53eaf..e5421cd4 100644 --- a/core/builtins.zig +++ b/core/builtins.zig @@ -414,6 +414,25 @@ pub const Exec = struct { } }; +/// Run its argument as Exec does, at the project's root. +/// +/// The root is the nearest directory at or above this pane's holding a +/// `.jj` or a `.git`, else this pane's own. `Root make` runs make there in a +/// command pane; `Root Find` and `Root Grep` (`SPC f F`, `SPC f G`) search +/// from there, their heads `Find root` and `Grep root`, a Grep's leading +/// directory read from the root. Bare (`SPC :`), the `:` line, its head +/// `: root`, whose Enter runs the line there. +pub const Root = struct { + pub const takes_arg = true; + pub fn run(c: Ctx) void { + const line = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); + if (line.len == 0) return @import("Command.zig").open(c.p, c.pane, true); + c.p.exec_root = true; + defer c.p.exec_root = false; + _ = exec.executeFrom(c.p, c.id, line, c.from_body); + } +}; + // ---- session ---- /// Which panes a refusal asks about: every one (Exit, Restore), one (Del), |
