fix: clamp to end of last line if the cursor is past the end of the buffer
closes #289
This commit is contained in:
parent
251c74a23b
commit
fda9338a06
1 changed files with 6 additions and 2 deletions
|
@ -28,8 +28,12 @@ pub inline fn right_of(self: Self, other: Self) bool {
|
|||
}
|
||||
|
||||
pub fn clamp_to_buffer(self: *Self, root: Buffer.Root, metrics: Metrics) void {
|
||||
self.row = @min(self.row, root.lines() - 1);
|
||||
if (self.row > root.lines() - 1) {
|
||||
self.row = root.lines() - 1;
|
||||
self.col = root.line_width(self.row, metrics) catch 0;
|
||||
} else {
|
||||
self.col = @min(self.col, root.line_width(self.row, metrics) catch 0);
|
||||
}
|
||||
}
|
||||
|
||||
fn follow_target(self: *Self, root: Buffer.Root, metrics: Metrics) void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue