Fix crash when cursor moves off the screen when window resized
- Drawing as much as possible of the highlights.
This commit is contained in:
parent
97a211d03b
commit
83b0dcc002
1 changed files with 11 additions and 10 deletions
|
|
@ -262,10 +262,10 @@ class Editor:
|
||||||
result = appearance
|
result = appearance
|
||||||
if not self.is_editing:
|
if not self.is_editing:
|
||||||
return result
|
return result
|
||||||
|
cursor_y = self.cursor_y - view_y
|
||||||
if self.mark is None:
|
if self.mark is None:
|
||||||
with contextlib.suppress(IndexError): # Fix. The cursor should always be on screen.
|
if 0 <= cursor_y < len(result):
|
||||||
result[self.cursor_y - view_y] = highlight_str(result[self.cursor_y - view_y],
|
result[cursor_y] = highlight_str(result[cursor_y], termstr.Color.white, 0.8)
|
||||||
termstr.Color.white, 0.8)
|
|
||||||
else:
|
else:
|
||||||
(start_x, start_y), (end_x, end_y) = self.get_selection_interval()
|
(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]))
|
screen_start_x = len(expand_str(self.text_widget[start_y][:start_x]))
|
||||||
|
|
@ -287,13 +287,14 @@ class Editor:
|
||||||
result[end_y] = highlight_part(result[end_y], 0, screen_end_x)
|
result[end_y] = highlight_part(result[end_y], 0, screen_end_x)
|
||||||
if self.cursor_x >= len(result[0]):
|
if self.cursor_x >= len(result[0]):
|
||||||
result = fill3.appearance_resize(result, (self.cursor_x+1, len(result)))
|
result = fill3.appearance_resize(result, (self.cursor_x+1, len(result)))
|
||||||
cursor_line = result[self.cursor_y - view_y]
|
if 0 <= cursor_y < len(result):
|
||||||
screen_x = len(expand_str(self.text_widget[self.cursor_y][:self.cursor_x]))
|
cursor_line = result[cursor_y]
|
||||||
screen_x_after = (screen_x + 1 if self._current_character() in ["\t", "\n"]
|
screen_x = len(expand_str(self.text_widget[self.cursor_y][:self.cursor_x]))
|
||||||
else len(expand_str(self.text_widget[self.cursor_y][:self.cursor_x+1])))
|
screen_x_after = (screen_x + 1 if self._current_character() in ["\t", "\n"] else
|
||||||
result[self.cursor_y - view_y] = (
|
len(expand_str(self.text_widget[self.cursor_y][:self.cursor_x+1])))
|
||||||
cursor_line[:screen_x] + termstr.TermStr(cursor_line[screen_x:screen_x_after]).invert()
|
result[cursor_y] = (cursor_line[:screen_x] +
|
||||||
+ cursor_line[screen_x_after:])
|
termstr.TermStr(cursor_line[screen_x:screen_x_after]).invert() +
|
||||||
|
cursor_line[screen_x_after:])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def set_text(self, text):
|
def set_text(self, text):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue