emma
/
breed
Archived
forked from mars/breed
1
0
Fork 0

Fix clamped_cursor() OOB for 0-length lines

This commit is contained in:
mars 2023-04-12 19:33:28 -04:00
parent 417294921a
commit b7715532f8
1 changed files with 3 additions and 3 deletions

View File

@ -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),
}
}