Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Change update_all to update_current on editor changes #11010

Merged
merged 5 commits into from Dec 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 31 additions & 5 deletions spyder/plugins/outlineexplorer/widgets.py
Expand Up @@ -338,12 +338,12 @@ def connect_current_editor(self, state):
sig_update = editor.sig_outline_explorer_data_changed
sig_move = editor.sig_cursor_position_changed
if state:
sig_update.connect(self.update_all)
sig_update.connect(self.update_current)
sig_move.connect(self.do_follow_cursor)
self.do_follow_cursor()
else:
try:
sig_update.disconnect(self.update_all)
sig_update.disconnect(self.update_current)
sig_move.disconnect(self.do_follow_cursor)
except TypeError:
# This catches an error while performing
Expand Down Expand Up @@ -399,14 +399,40 @@ def file_renamed(self, editor, new_filename):

@Slot()
def update_all(self):
"""
Update the outline explorer for all editors tree preserving the tree
state
"""
self.save_expanded_state()
for editor, editor_id in list(self.editor_ids.items()):
item = self.editor_items[editor_id]
tree_cache = self.editor_tree_cache[editor_id]
self.populate_branch(editor, item, tree_cache)
self.__do_update(editor, editor_id)
self.restore_expanded_state()
self.do_follow_cursor()

@Slot()
def update_current(self):
"""
Update the outline explorer for the current editor tree preserving the
tree state
"""
plugin_base = self.parent().parent()
if getattr(plugin_base, "_isvisible", True):
self.save_expanded_state()
editor = self.current_editor
editor_id = editor.get_id()
self.__do_update(editor, editor_id)
self.restore_expanded_state()
self.do_follow_cursor()

def __do_update(self, editor, editor_id):
"""
Recalculate the and update the tree items in the Outliner for a
given editor
"""
item = self.editor_items[editor_id]
tree_cache = self.editor_tree_cache[editor_id]
self.populate_branch(editor, item, tree_cache)

def remove_editor(self, editor):
if editor in self.editor_ids:
if self.current_editor is editor:
Expand Down