diff options
Diffstat (limited to 'src/File.zig')
| -rw-r--r-- | src/File.zig | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/File.zig b/src/File.zig index ddf91af3..5db04443 100644 --- a/src/File.zig +++ b/src/File.zig @@ -587,12 +587,18 @@ test "indexed source rows match uncached scans across content changes" { /// else none. Every mapping between a file row's bytes and its cells goes /// through here, so the drawn row, the caret and a click cannot disagree. pub fn rowPads(pane: *const Pane, row: i32, out: *[Tables.max_pads]Tables.Pad) []const Tables.Pad { - const f = if (pane.file) |*file| file else return &.{}; - if (row < 0 or f.tables.list.items.len == 0 or !f.tables.current(f)) return &.{}; - const table = f.tables.find(@intCast(row)) orelse return &.{}; + const table = rowTable(pane, row) orelse return &.{}; + return pane.file.?.tables.padsOf(table, sourceLine(pane, row), out); +} + +/// The table `row` is laid out in, in this pane (`rowPads`). +pub fn rowTable(pane: *const Pane, row: i32) ?*const Tables.Table { + const f = if (pane.file) |*file| file else return null; + if (row < 0 or f.tables.list.items.len == 0 or !f.tables.current(f)) return null; + const table = f.tables.find(@intCast(row)) orelse return null; const width = wrapWidth(pane, pane.body_wrapped); - if (width > 0 and table.width > width) return &.{}; - return f.tables.padsOf(table, sourceLine(pane, row), out); + if (width > 0 and table.width > width) return null; + return table; } pub fn displayOffset(pane: *const Pane, row: i32, from_raw: i32, to_raw: i32) i32 { |
