From ee3f269d93bf2816771361ef79f22192bba2ecee Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 13 Nov 2020 12:51:52 +0100 Subject: [PATCH] Fix numeric underflow when text editing --- egui/src/paint/font.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egui/src/paint/font.rs b/egui/src/paint/font.rs index 3435adc3..18662d87 100644 --- a/egui/src/paint/font.rs +++ b/egui/src/paint/font.rs @@ -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;