diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 01:01:35 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 9d2e07e997de155c7dbb894a79e5c11839eab39e (patch) | |
| tree | 45d09fbe224693b2b9426213e59e56d5b1f35224 /src/pardes.zig | |
| parent | 425d9beb9c977df364ed83743cb2efdef9429478 (diff) | |
| download | pardes-9d2e07e997de155c7dbb894a79e5c11839eab39e.tar.gz pardes-9d2e07e997de155c7dbb894a79e5c11839eab39e.zip | |
Scroll a tag taller than its rows to keep its caret in view
A tag shows at most eight rows, so a longer one (a 9P write of many lines, or
`o` in the tag) put its caret on a line that was never drawn. Pane, column and
workspace tags now keep a first line on screen that follows the caret while
they have the keyboard, and the pointer and the pane text count their rows
from it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index c802f0ea..40e49d6a 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3771,6 +3771,9 @@ pub const Pardes = struct { /// A mouse sweep is extending the focused header's selection. header_drag: bool = false, header_scroll: usize = 0, + /// The focused header's first line on screen, which follows its caret + /// when it has more lines than rows. + header_top: usize = 0, ov_pinch_scale: f32 = 1.0, ov_touch_scroll_delta: f32 = 0.0, /// middle+left chord argument: a kept left selection captured by a left @@ -5533,6 +5536,13 @@ pub const Pardes = struct { const lines = std.mem.count(u8, tagline.curTail(pane), "\n") + 1; pane.tag_rows = @intCast(@min(lines, MAX_TAG_ROWS, @max(BOX_H, r.h -| 1))); if (pane.collapsed) pane.tag_rows = BOX_H; + if (pane.focus == .tag and pane.prompt != .name) { + const cur: usize = @intCast(@max(0, pane.tag.cur_row)); + var top: usize = pane.tag_top; + if (cur < top) top = cur; + if (cur >= top + pane.tag_rows) top = cur + 1 - pane.tag_rows; + pane.tag_top = @intCast(@min(top, lines - pane.tag_rows)); + } else pane.tag_top = 0; const cols = @max(1, r.w -| config.GUTTER); const rows = @max(1, r.h -| pane.tag_rows); // the tag steals the top rows if ((cols != pane.cols or rows != pane.rows) and r.h > pane.tag_rows) { |
