Only recalculate diff after change actions
This commit is contained in:
parent
036b0a8862
commit
eb5254961b
2 changed files with 10 additions and 3 deletions
|
|
@ -327,8 +327,9 @@ class DiffEditor:
|
||||||
or self.KEY_MAP.get(term_code)):
|
or self.KEY_MAP.get(term_code)):
|
||||||
action(self)
|
action(self)
|
||||||
else:
|
else:
|
||||||
self.editors[0].on_keyboard_input(term_code)
|
is_content_changed = self.editors[0].on_keyboard_input(term_code)
|
||||||
self.diff_changed()
|
if is_content_changed:
|
||||||
|
self.diff_changed()
|
||||||
self.previous_term_code = term_code
|
self.previous_term_code = term_code
|
||||||
fill3.APPEARANCE_CHANGED_EVENT.set()
|
fill3.APPEARANCE_CHANGED_EVENT.set()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -780,6 +780,7 @@ class TextEditor:
|
||||||
self.history.append((self.text_widget.lines.copy(), self._cursor_x, self._cursor_y))
|
self.history.append((self.text_widget.lines.copy(), self._cursor_x, self._cursor_y))
|
||||||
self.history_position = len(self.history)
|
self.history_position = len(self.history)
|
||||||
|
|
||||||
|
@change_action
|
||||||
def undo(self):
|
def undo(self):
|
||||||
if self.history_position == 0:
|
if self.history_position == 0:
|
||||||
self.ring_bell()
|
self.ring_bell()
|
||||||
|
|
@ -856,10 +857,13 @@ class TextEditor:
|
||||||
if self.parts_widget is not None:
|
if self.parts_widget is not None:
|
||||||
self.parts_widget.on_keyboard_input(term_code)
|
self.parts_widget.on_keyboard_input(term_code)
|
||||||
return
|
return
|
||||||
|
is_content_changed = False
|
||||||
if action := (TextEditor.KEY_MAP.get((self.previous_term_code, term_code))
|
if action := (TextEditor.KEY_MAP.get((self.previous_term_code, term_code))
|
||||||
or TextEditor.KEY_MAP.get(term_code)):
|
or TextEditor.KEY_MAP.get(term_code)):
|
||||||
if action.__name__ == "wrapper":
|
if action.__name__ == "wrapper":
|
||||||
self.add_to_history()
|
if action != TextEditor.undo:
|
||||||
|
self.add_to_history()
|
||||||
|
is_content_changed = True
|
||||||
try:
|
try:
|
||||||
action(self)
|
action(self)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|
@ -867,9 +871,11 @@ class TextEditor:
|
||||||
elif not (len(term_code) == 1 and ord(term_code) < 32):
|
elif not (len(term_code) == 1 and ord(term_code) < 32):
|
||||||
self.add_to_history()
|
self.add_to_history()
|
||||||
self.insert_text(term_code, is_overwriting=self.is_overwriting)
|
self.insert_text(term_code, is_overwriting=self.is_overwriting)
|
||||||
|
is_content_changed = True
|
||||||
self.previous_term_code = term_code
|
self.previous_term_code = term_code
|
||||||
self.follow_cursor()
|
self.follow_cursor()
|
||||||
fill3.APPEARANCE_CHANGED_EVENT.set()
|
fill3.APPEARANCE_CHANGED_EVENT.set()
|
||||||
|
return is_content_changed
|
||||||
|
|
||||||
def scroll(self, dx, dy):
|
def scroll(self, dx, dy):
|
||||||
view_x, view_y = self.scroll_position
|
view_x, view_y = self.scroll_position
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue