diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:28:40 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:21:29 -0300 |
| commit | 8cbd23a7dca97d7438e07f494c0592ad7da120f6 (patch) | |
| tree | 588a089c9cc4deae690977dc58d2e81af365ebf7 | |
| parent | 034ac8e5128e3dc917b3a98bead6db71a5249739 (diff) | |
| download | pardes-8cbd23a7dca97d7438e07f494c0592ad7da120f6.tar.gz pardes-8cbd23a7dca97d7438e07f494c0592ad7da120f6.zip | |
tagline: a tag and a header take the keyboard through one takeKeyboard (the cursor pulled back inside the text, nothing selected or pending, normal mode) where enterTag and enterHeader each ended in their own copy of it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | src/tagline.zig | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/tagline.zig b/src/tagline.zig index 66a037f2..317c1c17 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -225,21 +225,27 @@ pub fn enterTag(p: *Pardes, pane: *Pane) void { t.cur_col = @intCast(cursor.col); t.cur_pinned = true; } - // The text may have changed since (a 9P write, a rename), so the - // remembered cursor is pulled back inside it. It is the cursor that - // is remembered, not a selection. - const rows = modal.cursorLineCount(whole); + takeKeyboard(t, whole); + t.sticky_col = -1; + pane.focus = .tag; +} + +/// A tag or a header taking the keyboard in normal mode: its cursor where +/// it was, pulled back inside `text` (it may have changed since: a 9P +/// write, a rename), and nothing selected or pending. It is the cursor that +/// is remembered, not a selection. +fn takeKeyboard(t: *Text, text: []const u8) void { + const rows = modal.cursorLineCount(text); t.cur_row = @intCast(@min(@as(usize, @intCast(@max(0, t.cur_row))), rows - 1)); - const line = modal.lineSlice(whole, @intCast(t.cur_row)); + const line = modal.lineSlice(text, @intCast(t.cur_row)); t.cur_col = @intCast(modal.graphemeStart(line, @min(line.len, @as(usize, @intCast(@max(0, t.cur_col)))))); + t.cur_pinned = true; t.vsel.active = false; t.nsel = 0; t.select = false; t.restore_cursor = false; - t.sticky_col = -1; t.mode = .normal; t.normal.clear(); - pane.focus = .tag; } /// A pane's tag as it is shown: its lines, each wrapped onto more rows at @@ -407,18 +413,7 @@ pub fn enterHeader(p: *Pardes, column: ?usize) void { p.header_column = column; if (column) |c| p.setActiveColumn(c); const t = focusedHeader(p) orelse return exitHeader(p); - const text = edit.flatSurface(p, t) catch ""; - const rows = modal.cursorLineCount(text); - t.cur_row = @intCast(@min(@as(usize, @intCast(@max(0, t.cur_row))), rows - 1)); - const line = modal.lineSlice(text, @intCast(t.cur_row)); - t.cur_col = @intCast(modal.graphemeStart(line, @min(line.len, @as(usize, @intCast(@max(0, t.cur_col)))))); - t.cur_pinned = true; - t.vsel.active = false; - t.nsel = 0; - t.select = false; - t.restore_cursor = false; - t.mode = .normal; - t.normal.clear(); + takeKeyboard(t, edit.flatSurface(p, t) catch ""); } /// The span a header's selection covers on line `row` of its text, in |
