Fix numeric underflow when text editing

This commit is contained in:
Emil Ernerfeldt 2020-11-13 12:51:52 +01:00
parent 9057eaec7e
commit ee3f269d93

View file

@ -101,7 +101,7 @@ impl Galley {
if y_dist < best_y_dist {
best_y_dist = y_dist;
let mut column = line.char_at(pos.x);
if column == line.char_count() && line.ends_with_newline {
if column == line.char_count() && line.ends_with_newline && column > 0 {
// handle the case where line ends with a \n and we click after it.
// We should return the position BEFORE the \n!
column -= 1;