From fb72c2402fa1b1ae99be64fe7b2947ea5dd42623 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 01:05:11 -0300 Subject: 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 --- src/tagline.zig | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/tagline.zig') 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 -- cgit v1.3