summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 09:16:36 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commita9de2b51ab76a43250a4d6c41a0ddd54e6970049 (patch)
treea2138ead27f434026c224fd8b926f66b7fd7fe0c /src/ninep
parent0d04bc9214cccce42d74862b31376d49bdda3956 (diff)
downloadpardes-a9de2b51ab76a43250a4d6c41a0ddd54e6970049.tar.gz
pardes-a9de2b51ab76a43250a4d6c41a0ddd54e6970049.zip
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 <[email protected]>
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/pane.zig7
1 files changed, 4 insertions, 3 deletions
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" {