diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 01:05:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | fb72c2402fa1b1ae99be64fe7b2947ea5dd42623 (patch) | |
| tree | 2ddaa866f23bf8ce44cc2d2dc315ede7e4b8a263 /src/tagline.zig | |
| parent | 9d2e07e997de155c7dbb894a79e5c11839eab39e (diff) | |
| download | pardes-fb72c2402fa1b1ae99be64fe7b2947ea5dd42623.tar.gz pardes-fb72c2402fa1b1ae99be64fe7b2947ea5dd42623.zip | |
Let a tag's computed prefix bring its own separating space
The space between a pane's path and its commands belongs to the tag's own
text, so deleting it, or truncating the 9P tag and writing `Get`, ran the
path and the word together for Look and Exec. The prefix now adds a space
whenever the text does not start with one; every default text does, so the
default tags read and render as before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tagline.zig')
| -rw-r--r-- | src/tagline.zig | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/tagline.zig b/src/tagline.zig index a918689b..8bd8000a 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -104,19 +104,27 @@ pub fn revealHeader(p: *Pardes) void { pub fn tagPrefix(p: *Pardes, pane: *Pane) ![]u8 { const arena = p.scratch.allocator(); - if (comptime pdf_enabled) if (pane.pdf) |pv| return std.fmt.allocPrint( - arena, - "{s} [{d}/{d}]", - .{ pv.path, pv.page + 1, pv.page_count }, - ); - if (pane.image) |*state| return panes.Image.tagPrefix(arena, state); - if (pane.file) |f| { - const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path; - if (panes.Output.fileTraits(f.output).saves and f.revision != f.saved_revision) - return std.fmt.allocPrint(arena, "{s}{s}", .{ name, dirty_marker }); - return arena.dupe(u8, name); - } - return arena.dupe(u8, pane.cwdSlice()); + const prefix = prefix: { + if (comptime pdf_enabled) if (pane.pdf) |pv| + break :prefix try std.fmt.allocPrint(arena, "{s} [{d}/{d}]", .{ pv.path, pv.page + 1, pv.page_count }); + if (pane.image) |*state| break :prefix try panes.Image.tagPrefix(arena, state); + if (pane.file) |f| { + const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path; + if (panes.Output.fileTraits(f.output).saves and f.revision != f.saved_revision) + break :prefix try std.fmt.allocPrint(arena, "{s}{s}", .{ name, dirty_marker }); + break :prefix name; + } + break :prefix pane.cwdSlice(); + }; + // The space between the prefix and the tag's own text is the text's + // (every default starts with one), but the prefix is computed, so it + // cannot trust the text to keep it: with it deleted, Look and Exec + // would see the path and the first word as one. The prefix brings its + // own then. + const tail = curTail(pane); + if (tail.len > 0 and std.mem.indexOfScalar(u8, " \t\n", tail[0]) == null) + return std.fmt.allocPrint(arena, "{s} ", .{prefix}); + return arena.dupe(u8, prefix); } /// The tag's own text: what the user made of it, or until then the |
