diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 13:38:45 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 65a4c17767f175ce16cbbce5520a86926d61692d (patch) | |
| tree | 92c1de60b2be3a79cfffb474e38efd546b20daa0 /src/exec.zig | |
| parent | c4504325deefd4a8fb905db95b4e8b5003fb2a6a (diff) | |
| download | pardes-65a4c17767f175ce16cbbce5520a86926d61692d.tar.gz pardes-65a4c17767f175ce16cbbce5520a86926d61692d.zip | |
With no pane at all, the root look opens its file and the root exec runs its command in the session's directory
/look and /exec run at the active pane, and with every pane closed they
failed ENOENT, "file does not exist", about a file the writer never
named. Now an exec runs as the workspace tag's would, in the session's
directory: a builtin at the stand-in, a command in a command pane. An
empty window's click now runs a command line too, not only session words.
A look runs from a scratch made as New makes one, which also makes the
column. That scratch is dropped, unannounced, when the look went to
another pane, so opening a file leaves only the file.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/exec.zig b/src/exec.zig index eed9297a..6070d038 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -644,11 +644,12 @@ pub fn execute(p: *Pardes, id: usize, txt: []const u8) ?usize { /// such text may be a bound REPL's. Run by name (`Exec ...`, whose line /// comes back through `execute`) or written as a command word, never. pub fn executeFrom(p: *Pardes, id: usize, txt: []const u8, from_body: bool) ?usize { - // An empty window runs its session words, and nothing else: no pane to - // run a command for. + // An empty window runs its session words, and a command line in the + // session's directory (execDir), as its workspace tag would. const pane = p.panes[id] orelse { - _ = executeBuiltinLine(p, id, commandText(txt)); - return null; + const cmd = commandText(txt); + if (cmd.len == 0 or executeBuiltinLine(p, id, cmd)) return null; + return runCommand(p, id, cmd); }; const gesture = from_body and config.commandWord(std.mem.trim(u8, txt, " \t\r\n")) == null; const cmd = commandText(txt); @@ -699,7 +700,9 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { p.reportFailure(from, "exec: a command line is at most 1024 bytes"); return null; } - const src = p.panes[from] orelse return null; + // None asking (an empty window): the session's directory, no pane of + // its own to reuse. + const src = p.panes[from]; const dir = p.execDir(from); // A directory that is not there runs nothing, as Tty makes nothing // there: no pane, and the write fails ENOENT. @@ -712,7 +715,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { // would hang that job up. // From a column's tag, only a finished pane in that column is reused, // as the new one goes in that column (placeNew). - const reuse: ?usize = if (p.exec_column == null and src.command != null and src.command_done and !src.command_pty) from else for (p.panes, 0..) |slot, i| { + const reuse: ?usize = if (p.exec_column == null and src != null and src.?.command != null and src.?.command_done and !src.?.command_pty) from else for (p.panes, 0..) |slot, i| { const other = slot orelse continue; if (p.exec_column) |c| if (if (layout.findPane(p, i)) |f| f.col != c else true) continue; if (other.command != null and other.command_done and !other.command_pty and std.mem.eql(u8, other.cwdSlice(), dir)) break i; |
