Skip to content

Commit 4d04d6f

Browse files
committed
diff: remove self.mode state
We already have a reference to the model so it's simpler to just check at runtime instead of storing state and using a callback to update it. Signed-off-by: David Aguilar <davvid@gmail.com>
1 parent aa96e80 commit 4d04d6f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

cola/widgets/diff.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class DiffEditor(DiffTextEdit):
3434
def __init__(self, parent):
3535
DiffTextEdit.__init__(self, parent)
3636
self.model = model = main.model()
37-
self.mode = self.model.mode_none
3837

3938
self.action_process_section = qtutils.add_action(self,
4039
N_('Process Section'),
@@ -76,8 +75,6 @@ def __init__(self, parent):
7675
self.stage_selection)
7776
self.action_apply_selection.setIcon(qtutils.apply_icon())
7877

79-
model.add_observer(model.message_mode_about_to_change,
80-
self._mode_about_to_change)
8178
model.add_observer(model.message_diff_text_changed, self._emit_text)
8279

8380
self.connect(self, SIGNAL('copyAvailable(bool)'),
@@ -172,13 +169,11 @@ def mousePressEvent(self, event):
172169

173170
return DiffTextEdit.mousePressEvent(self, event)
174171

175-
def _mode_about_to_change(self, mode):
176-
self.mode = mode
177-
178172
def setPlainText(self, text):
179173
"""setPlainText(str) while retaining scrollbar positions"""
180-
highlight = (self.mode != self.model.mode_none and
181-
self.mode != self.model.mode_untracked)
174+
mode = self.model.mode
175+
highlight = (mode != self.model.mode_none and
176+
mode != self.model.mode_untracked)
182177
self.highlighter.set_enabled(highlight)
183178

184179
scrollbar = self.verticalScrollBar()

0 commit comments

Comments
 (0)