diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 14:53:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 12c257e624d3f1f80ca3df041b54026ff772d638 (patch) | |
| tree | 6bba52da1148e167ed695e219bb3a9c742337d95 /src/look.zig | |
| parent | e56a8ba396566eaab818b6c742850b5842e880bb (diff) | |
| download | pardes-12c257e624d3f1f80ca3df041b54026ff772d638.tar.gz pardes-12c257e624d3f1f80ca3df041b54026ff772d638.zip | |
A path typed with a leading ~ is the home directory, at every entry point that takes one, through one helper
Only DumpDir (dump.zig) and ShaderBuild expanded `~/`, each its own way.
So a look at `~/notes.txt`, `name ~/x`, `Save ~/x`, ThemeFile, Restore and
a quoted `pardes '~/x'` all took `~` as a directory of that name under the
pane's. There is now one rule, filesystem.expandHome. A leading `~`,
alone or before `/` or `:`, is $HOME, else the passwd entry's home;
`~user` is that user's (getpwnam). As in a shell, it applies even beside a
file named `~`, and `./~` names that file. Every entry point runs its
typed path through it:
- look, B3 and 9P, before any parsing, so `~/x:12`, `~/x:12:3` and
`~/x:/re/` all work;
- name, and a tag's rename;
- Save <path>;
- ThemeFile, DumpDir, Restore and ShaderBuild's shader files;
- the forwarding launch.
Recent rows are not shown with `~` and need nothing. How names are shown
is unchanged.
Tests: expandHome's cases, and HOME unset (passwd), with HOME passed in
rather than set, since setenv moves the environ a spawned child reads.
fs.py covers Save into missing directories under `~`, `name ~/x`, a look
at `~/x:3`, and a forwarded `pardes '~/x'`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/look.zig')
| -rw-r--r-- | src/look.zig | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/look.zig b/src/look.zig index de51804d..357a9c63 100644 --- a/src/look.zig +++ b/src/look.zig @@ -1499,8 +1499,11 @@ fn isRecentList(pane: *const Pane) bool { return std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Recent }) or std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Jumplist }); } -pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { +pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { const pane = p.panes[id] orelse return; + // `~/x`, `~/x:12`, `~/x:/re/`: home, before anything reads the text. + var home_buf: [4096]u8 = undefined; + const operand = filesystem.expandHome(std.mem.trim(u8, operand_raw, " \t\r\n"), &home_buf); // A +Recent row is a remembered place: reopened and clamped to the file // as it is now, never a miss for a line the file no longer has. if (isRecentList(pane)) { |
