Fix clamped_cursor() OOB for 0-length lines
This commit is contained in:
parent
417294921a
commit
b7715532f8
|
@ -199,11 +199,11 @@ impl Buffer {
|
|||
}
|
||||
|
||||
pub fn clamped_cursor(&self, cursor: Cursor) -> Cursor {
|
||||
let line_end = self.text.line(cursor.line).len_chars().saturating_sub(1);
|
||||
|
||||
Cursor {
|
||||
line: cursor.line,
|
||||
column: cursor
|
||||
.column
|
||||
.min(self.text.line(cursor.line).len_chars() - 1),
|
||||
column: cursor.column.min(line_end),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue