From a9de2b51ab76a43250a4d6c41a0ddd54e6970049 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 09:16:36 -0300 Subject: Let the keyboard reach a tag's path, read-only The tag's computed path, dirty marker and page were out of the keyboard's reach: its cursor lived in the text after them. It now lives in the tag as shown, as in acme where the name is ordinary text at the start of the tag, so `0` goes to the line's start and motions select and yank the path. The path stays read-only: an edit that would change it is refused and leaves the cursor where it was, and typing into a file's path drafts a new name as a click on it does. Sync moves the tag's positions when the prefix changes length, so a rename or the dirty marker still never moves the cursor off the text after it. Co-Authored-By: Claude Opus 5.5 --- src/ninep/pane.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ninep') diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 80dd97cd..64355e0e 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -613,8 +613,9 @@ pub fn truncate(p: *Pardes, pane: *Pane, file: PaneFile) tree.Status { pane.tag.remember(p.gpa, if (pane.tag.own) |own| .{ .text = own } else null); if (pane.tag.own) |own| p.gpa.free(own); pane.tag.own = empty; + // what is left is the prefix; the cursor goes after it pane.tag.cur_row = 0; - pane.tag.cur_col = 0; + pane.tag.cur_col = if (tagline.pathPrefix(p.scratch.allocator(), pane)) |prefix| @intCast(prefix.len) else |_| 0; pane.tag.vsel.active = false; pane.tag.nsel = 0; }, @@ -910,9 +911,9 @@ test "truncating the tag clears its editable tail" { try testing.expectEqualStrings("/test.txt Get", whole); const word = config.wordBounds(whole, whole.len - "Get".len); try testing.expectEqualStrings("Get", whole[word.lo..word.hi]); - // and the keyboard's first column of the text is the G + // and a click on the G puts the tag's cursor on it const at = tagline.tagOffsetAt(p, pane, 0, "/test.txt ".len).?; - try testing.expectEqual(@as(usize, 0), at.col); + try testing.expectEqualStrings("Get", whole[at.col..]); } test "name reads the file name and writing it promotes a scratch without touching its body" { -- cgit v1.3