~jamii/focus

8ada093730f125e400c833ca18b0c2b1bf7958ef — Jamie Brandon 10 months ago 90a4739
Bugfixes
2 files changed, 4 insertions(+), 4 deletions(-)

M lib/focus/buffer.zig
M lib/focus/buffer_tree.zig
M lib/focus/buffer.zig => lib/focus/buffer.zig +3 -3
@@ 241,10 241,10 @@ pub const Buffer = struct {
        return self.tree.getPointForLineStart(line).?.pos;
    }

    // TODO should handle line out of range too?
    /// Panics on line out of range. Handles col out of range by truncating to end of line.
    /// Handles line out of range by returning end of file.
    /// Handles col out of range by returning end of line.
    pub fn getPosForLineCol(self: *Buffer, line: usize, col: usize) usize {
        const start_point = self.tree.getPointForLineStart(line).?;
        const start_point = self.tree.getPointForLineStart(line) orelse return self.getBufferEnd();
        var end_point = start_point;
        _ = end_point.searchForwards("\n");
        return start_point.pos + min(col, end_point.pos - start_point.pos);

M lib/focus/buffer_tree.zig => lib/focus/buffer_tree.zig +1 -1
@@ 162,7 162,7 @@ pub const BufferTree = struct {
        }
        const leaf = node.asLeaf();

        if (lines_remaining > leaf.state.newlines.items.len)
        if (lines_remaining >= leaf.state.newlines.items.len)
            return null;
        const offset = leaf.state.newlines.items[lines_remaining] + 1;