Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
'sort_files_alphabetically': False,
'show_comments': True,
'follow_cursor': True,
'update_on_save': False,
'display_variables': False,
'show_with_maximized_editor': True,
}),
Expand Down
14 changes: 14 additions & 0 deletions spyder/plugins/editor/widgets/codeeditor/lsp_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,14 @@ def apply_code_folding(self, folding_info):

self.folding_in_sync = True

def update_outline_on_save(self, state):
if state:
self._timer_sync_symbols_and_folding.timeout.disconnect()
else:
self._timer_sync_symbols_and_folding.timeout.connect(
self.sync_symbols_and_folding, Qt.UniqueConnection
)

# ---- Save/close file
# -------------------------------------------------------------------------
@schedule_request(method=CompletionRequestTypes.DOCUMENT_DID_SAVE,
Expand All @@ -1328,6 +1336,12 @@ def notify_save(self):
if self.save_include_text:
params['text'] = self.get_text_with_eol()
return params

@handles(CompletionRequestTypes.DOCUMENT_DID_SAVE)
def process_save(self):
if self.oe_proxy is not None:
if self.oe_proxy.update_on_save:
self.sync_symbols_and_folding()

@request(method=CompletionRequestTypes.DOCUMENT_DID_CLOSE,
requires_response=False)
Expand Down
9 changes: 9 additions & 0 deletions spyder/plugins/editor/widgets/editorstack/editorstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ def display_help(self, help_text, clicked):
self.send_to_help(name, help_text, force=True)

# ---- Editor Widget Settings
@on_conf_change(section='outline_explorer', option='update_on_save')
def on_outlineexplorer_update_on_save_change(self, value):
self.set_outline_update_on_save(value)

@on_conf_change(section='help', option='connect/editor')
def on_help_connection_change(self, value):
self.set_help_enabled(value)
Expand Down Expand Up @@ -930,6 +934,11 @@ def set_tab_stop_width_spaces(self, tab_stop_width_spaces):
def set_help_enabled(self, state):
self.help_enabled = state

def set_outline_update_on_save(self, state):
for finfo in self.data:
editor = finfo.editor
editor.update_outline_on_save(state)

def set_default_font(self, font, color_scheme=None):
self.default_font = font
if color_scheme is not None:
Expand Down
3 changes: 3 additions & 0 deletions spyder/plugins/outlineexplorer/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def __init__(self, editor, fname):
# latest info available here
self.is_tree_updated = False

# To decide if the outline has be updated when saving the file
self.update_on_save = False

def update_outline_info(self, info):
logger.debug(
f"Updating info for proxy {id(self)} of file {self.fname}"
Expand Down
11 changes: 10 additions & 1 deletion spyder/plugins/outlineexplorer/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class OutlineExplorerActions:
DisplayVariables = 'display_variables'
FollowCursor = 'follow_cursor'
SortFiles = 'sort_files_alphabetically'
UpdateOnSave = 'update_on_save'


# ---- Main widget
Expand Down Expand Up @@ -141,6 +142,13 @@ def setup(self):
option='follow_cursor'
)

update_on_save_act = self.create_action(
OutlineExplorerActions.UpdateOnSave,
text=_("Update when saving the file"),
toggled=True,
option='update_on_save'
)

sort_files_alphabetically_act = self.create_action(
OutlineExplorerActions.SortFiles,
text=_('Sort files alphabetically'),
Expand All @@ -150,7 +158,8 @@ def setup(self):

actions = [fullpath_act, allfiles_act, group_cells_act,
display_variables_act, follow_cursor_act, comment_act,
sort_files_alphabetically_act, fromcursor_act]
update_on_save_act, sort_files_alphabetically_act,
fromcursor_act]

option_menu = self.get_options_menu()
for action in actions:
Expand Down
12 changes: 12 additions & 0 deletions spyder/plugins/outlineexplorer/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def __init__(self, parent):
self.sort_files_alphabetically = self.get_conf(
'sort_files_alphabetically')
self.follow_cursor = self.get_conf('follow_cursor')
self.update_on_save = self.get_conf('update_on_save')
self.display_variables = self.get_conf('display_variables')

super().__init__(parent)
Expand Down Expand Up @@ -324,6 +325,14 @@ def toggle_show_comments(self, state):
self.sig_update_configuration.emit()
self.update_editors(language='python')

@on_conf_change(option='update_on_save')
def toggle_update_on_save(self, state):
editor = self.current_editor
if state:
editor.update_on_save = True
else:
editor.update_on_save = False

@on_conf_change(option='group_cells')
def toggle_group_cells(self, state):
self.group_cells = state
Expand Down Expand Up @@ -617,6 +626,9 @@ def update_tree(self, items, editor):
self.sig_hide_spinner.emit()
return False

if self.update_on_save:
return False

logger.debug(f"Updating tree for file {editor.fname}")

# Create nodes with new tree
Expand Down
Loading