Fix crash when switching to non-existant line

- When switching from an insert area at the bottom of a file.
This commit is contained in:
Andrew Hamilton 2022-03-15 10:21:23 +10:00
parent 54f3b94caf
commit 365a76c4ed
2 changed files with 5 additions and 3 deletions

View file

@ -263,8 +263,9 @@ class Editor:
if not self.is_editing:
return result
if self.mark is None:
result[self.cursor_y - view_y] = highlight_str(result[self.cursor_y - view_y],
termstr.Color.white, 0.8)
with contextlib.suppress(IndexError): # Fix. The cursor should always be on screen.
result[self.cursor_y - view_y] = highlight_str(result[self.cursor_y - view_y],
termstr.Color.white, 0.8)
else:
(start_x, start_y), (end_x, end_y) = self.get_selection_interval()
screen_start_x = len(expand_str(self.text_widget[start_y][:start_x]))