Fix crashes during scrolling
- Occured due to negative scroll positions or not finding the equivalent line in the other editor.
This commit is contained in:
parent
7986f1c7d9
commit
87e62e8570
3 changed files with 4 additions and 5 deletions
2
BUGS
2
BUGS
|
|
@ -1,5 +1,4 @@
|
||||||
Current:
|
Current:
|
||||||
- Error sometimes when paging to the bottom of the file.
|
|
||||||
|
|
||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
|
|
@ -8,6 +7,7 @@ Fixed:
|
||||||
- When largest line grows the bounding box should grow.
|
- When largest line grows the bounding box should grow.
|
||||||
- Input can be lost when typing quickly and diff-edit is busy.
|
- Input can be lost when typing quickly and diff-edit is busy.
|
||||||
Seen with rapid undo while diffing.
|
Seen with rapid undo while diffing.
|
||||||
|
- Error sometimes when paging to the bottom of the file.
|
||||||
|
|
||||||
|
|
||||||
Won't fix:
|
Won't fix:
|
||||||
|
|
|
||||||
|
|
@ -182,15 +182,14 @@ class DiffEditor:
|
||||||
if left_start <= y < left_end:
|
if left_start <= y < left_end:
|
||||||
fraction = (y - left_start) / (left_end - left_start)
|
fraction = (y - left_start) / (left_end - left_start)
|
||||||
return round(right_start + fraction * (right_end - right_start))
|
return round(right_start + fraction * (right_end - right_start))
|
||||||
|
return 0
|
||||||
|
|
||||||
def follow_scroll(self):
|
def follow_scroll(self):
|
||||||
x, y = self.editors[0].scroll_position
|
x, y = self.editors[0].scroll_position
|
||||||
last_width, last_height = self.last_dimensions
|
last_width, last_height = self.last_dimensions
|
||||||
middle_y = last_height // 2
|
middle_y = last_height // 2
|
||||||
new_y = self._equivalent_line(y + middle_y)
|
new_y = self._equivalent_line(y + middle_y)
|
||||||
if new_y is None:
|
self.editors[1].scroll_position = max(0, x), max(0, new_y - middle_y)
|
||||||
new_y = 0
|
|
||||||
self.editors[1].scroll_position = max(0, x), new_y - middle_y
|
|
||||||
|
|
||||||
def switch_editor(self):
|
def switch_editor(self):
|
||||||
self.editors[1].cursor_x = self.editors[0].cursor_x
|
self.editors[1].cursor_x = self.editors[0].cursor_x
|
||||||
|
|
|
||||||
|
|
@ -658,7 +658,7 @@ class Editor:
|
||||||
|
|
||||||
def scroll(self, dx, dy):
|
def scroll(self, dx, dy):
|
||||||
view_x, view_y = self.scroll_position
|
view_x, view_y = self.scroll_position
|
||||||
self.scroll_position = view_x + dx, view_y + dy
|
self.scroll_position = max(0, view_x + dx), max(0, view_y + dy)
|
||||||
|
|
||||||
def on_mouse_press(self, x, y):
|
def on_mouse_press(self, x, y):
|
||||||
view_x, view_y = self.view_widget.position
|
view_x, view_y = self.view_widget.position
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue