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: Add button to debugger plugin to go to editor #19305

Merged
merged 4 commits into from
Sep 21, 2022
Merged
Changes from all 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
21 changes: 20 additions & 1 deletion spyder/plugins/debugger/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class DebuggerWidgetActions:
Step = "step"
Return = "return"
Stop = "stop"
GotoCursor = "go to editor"

# Toggles
ToggleExcludeInternal = 'toggle_exclude_internal_action'
Expand Down Expand Up @@ -263,6 +264,15 @@ def setup(self):
register_shortcut=True
)

goto_cursor_action = self.create_action(
DebuggerWidgetActions.GotoCursor,
text=_("Show in the editor the file and line where the debugger "
"is placed"),
icon=self.create_icon('fromcursor'),
triggered=self.goto_current_step,
register_shortcut=True
)

self.create_action(
DebuggerToolbarActions.DebugCurrentFile,
text=_("&Debug file"),
Expand Down Expand Up @@ -342,6 +352,7 @@ def setup(self):
step_action,
return_action,
stop_action,
goto_cursor_action,
enter_debug_action,
inspect_action,
search_action]:
Expand Down Expand Up @@ -404,7 +415,9 @@ def update_actions(self):
DebuggerWidgetActions.Continue,
DebuggerWidgetActions.Step,
DebuggerWidgetActions.Return,
DebuggerWidgetActions.Stop]:
DebuggerWidgetActions.Stop,
DebuggerWidgetActions.GotoCursor,
]:
action = self.get_action(action_name)
action.setEnabled(pdb_prompt)

Expand Down Expand Up @@ -499,6 +512,12 @@ def close_widget(self, widget):

# ---- Public API
# ------------------------------------------------------------------------
def goto_current_step(self):
"""Go to last pdb step."""
fname, lineno = self.get_pdb_last_step()
if fname:
self.sig_load_pdb_file.emit(fname, lineno)

def print_debug_file_msg(self):
"""Print message in the current console when a file can't be closed."""
widget = self.current_widget()
Expand Down