Skip to content

Commit

Permalink
improve closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Peter committed Aug 28, 2022
1 parent 6beefb6 commit 7fc3963
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions spyder/plugins/debugger/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,30 +148,33 @@ def on_editor_available(self):
# The editor is avilable, connect signal.
self.sig_debug_file.connect(self.debug_file)
self.sig_debug_cell.connect(self.debug_cell)
editor_shortcuts = {
DebuggerActions.DebugCurrentFile: self.debug_file,
DebuggerActions.DebugCurrentCell: self.debug_cell,
DebuggerActions.ToggleBreakpoint: self.set_or_clear_breakpoint,
DebuggerActions.ToggleConditionalBreakpoint:
self.set_or_edit_conditional_breakpoint,
}
editor.sig_codeeditor_created.connect(self.add_codeeditor)
editor.sig_codeeditor_changed.connect(self.update_codeeditor)
editor.sig_codeeditor_deleted.connect(self.remove_codeeditor)

# Apply shortcuts to editor and add actions to pythonfile list
editor_shortcuts = [
DebuggerActions.DebugCurrentFile,
DebuggerActions.DebugCurrentCell,
DebuggerActions.ToggleBreakpoint,
DebuggerActions.ToggleConditionalBreakpoint,
]
for name in editor_shortcuts:
action = self.get_action(name)
CONF.config_shortcut(
editor_shortcuts[name],
action.trigger,
context=self.CONF_SECTION,
name=name,
parent=editor)
editor.pythonfile_dependent_actions += [action]

# Add buttons to toolbar
for name in [
DebuggerActions.DebugCurrentFile,
DebuggerActions.DebugCurrentCell]:
action = self.get_action(name)
self.main.debug_toolbar_actions += [action]

editor.sig_codeeditor_created.connect(self.add_codeeditor)
editor.sig_codeeditor_changed.connect(self.update_codeeditor)
editor.sig_codeeditor_deleted.connect(self.remove_codeeditor)

@on_plugin_teardown(plugin=Plugins.Editor)
def on_editor_teardown(self):
editor = self.get_plugin(Plugins.Editor)
Expand All @@ -182,6 +185,24 @@ def on_editor_teardown(self):
editor.sig_codeeditor_changed.disconnect(self.update_codeeditor)
editor.sig_codeeditor_deleted.disconnect(self.remove_codeeditor)

# Remove editor actions
editor_shortcuts = [
DebuggerActions.DebugCurrentFile,
DebuggerActions.DebugCurrentCell,
DebuggerActions.ToggleBreakpoint,
DebuggerActions.ToggleConditionalBreakpoint,
]
for name in editor_shortcuts:
action = self.get_action(name)
editor.pythonfile_dependent_actions.remove(action)

# Remove buttons from toolbar
for name in [
DebuggerActions.DebugCurrentFile,
DebuggerActions.DebugCurrentCell]:
action = self.get_action(name)
self.main.debug_toolbar_actions.remove(action)

@on_plugin_available(plugin=Plugins.VariableExplorer)
def on_variable_explorer_available(self):
self.get_widget().sig_show_namespace.connect(
Expand Down

0 comments on commit 7fc3963

Please sign in to comment.