Skip to content

Commit

Permalink
Merge pull request #20557 from impact27/debug_plugin_to_run
Browse files Browse the repository at this point in the history
PR: Transition Debugger plugin actions to the Run plugin and cleanup Editor plugin
  • Loading branch information
ccordoba12 authored Feb 20, 2023
2 parents 47f55cd + d9440eb commit 8dc6d18
Show file tree
Hide file tree
Showing 24 changed files with 510 additions and 580 deletions.
5 changes: 3 additions & 2 deletions spyder/api/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ class SpyderToolbarMixin:
"""

def add_item_to_toolbar(self, action_or_widget, toolbar, section=None,
before=None):
before=None, before_section=None):
"""
If you provide a `before` action, the action will be placed before this
one, so the section option will be ignored, since the action will now
be placed in the same section as the `before` action.
"""
toolbar.add_item(action_or_widget, section=section, before=before)
toolbar.add_item(action_or_widget, section=section, before=before,
before_section=before_section)

def create_stretcher(self, id_=None):
"""
Expand Down
7 changes: 3 additions & 4 deletions spyder/app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from spyder.app import start
from spyder.config.base import get_home_dir, running_in_ci
from spyder.config.manager import CONF
from spyder.plugins.debugger.api import DebuggerToolbarActions
from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec
from spyder.plugins.projects.api import EmptyProject
from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor
Expand Down Expand Up @@ -394,8 +393,8 @@ def main_window(request, tmpdir, qtbot):
# it's used a lot.
toolbar = window.get_plugin(Plugins.Toolbar)
debug_toolbar = toolbar.get_application_toolbar(ApplicationToolbars.Debug)
debug_action = window.debugger.get_action(
DebuggerToolbarActions.DebugCurrentFile)
debug_action = window.run.get_action(
"run file in debugger")
debug_button = debug_toolbar.widgetForAction(debug_action)
window.debug_button = debug_button

Expand All @@ -415,7 +414,7 @@ def main_window(request, tmpdir, qtbot):
run_cell_and_advance_action)
window.run_cell_and_advance_button = run_cell_and_advance_button

run_selection_action = window.run.get_action('run selection')
run_selection_action = window.run.get_action('run selection and advance')
run_selection_button = run_toolbar.widgetForAction(run_selection_action)
window.run_selection_button = run_selection_button

Expand Down
30 changes: 14 additions & 16 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
get_home_dir, get_conf_path, get_module_path, running_in_ci)
from spyder.config.manager import CONF
from spyder.dependencies import DEPENDENCIES
from spyder.plugins.debugger.api import (
DebuggerWidgetActions, DebuggerToolbarActions)
from spyder.plugins.debugger.api import DebuggerWidgetActions
from spyder.plugins.externalconsole.api import ExtConsoleShConfiguration
from spyder.plugins.help.widgets import ObjectComboBox
from spyder.plugins.help.tests.test_plugin import check_text
Expand Down Expand Up @@ -634,8 +633,8 @@ def test_move_to_first_breakpoint(main_window, qtbot, debugcell):
Qt.LeftButton)

# Debug the cell
debug_cell_action = main_window.debugger.get_action(
DebuggerToolbarActions.DebugCurrentCell)
debug_cell_action = main_window.run.get_action(
"run cell in debugger")
with qtbot.waitSignal(shell.executed):
debug_cell_action.trigger()

Expand Down Expand Up @@ -1562,8 +1561,8 @@ def test_run_code(main_window, qtbot, tmpdir):
reset_run_code(qtbot, shell, code_editor, nsb)

# ---- Debug cell ------
debug_cell_action = main_window.debugger.get_action(
DebuggerToolbarActions.DebugCurrentCell)
debug_cell_action = main_window.run.get_action(
"run cell in debugger")
with qtbot.waitSignal(shell.executed):
debug_cell_action.trigger()
qtbot.keyClicks(shell._control, '!c')
Expand Down Expand Up @@ -1625,7 +1624,7 @@ def test_run_code(main_window, qtbot, tmpdir):
@flaky(max_runs=3)
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
@pytest.mark.parametrize('main_window',
[{'spy_config': ('editor', 'run_cell_copy', True)}],
[{'spy_config': ('run', 'run_cell_copy', True)}],
indirect=True)
@pytest.mark.order(after="test_debug_unsaved_function")
def test_run_cell_copy(main_window, qtbot, tmpdir):
Expand All @@ -1641,9 +1640,7 @@ def test_run_cell_copy(main_window, qtbot, tmpdir):
qtbot.waitUntil(
lambda: shell.spyder_kernel_ready and shell._prompt_html is not None,
timeout=SHELL_TIMEOUT)
# Make sure run_cell_copy is properly set
for editorstack in main_window.editor.editorstacks:
editorstack.set_run_cell_copy(True)

# Load test file
main_window.editor.load(filepath)

Expand Down Expand Up @@ -1680,7 +1677,7 @@ def test_run_cell_copy(main_window, qtbot, tmpdir):

# ---- Closing test file and reset config ----
main_window.editor.close_file()
CONF.set('editor', 'run_cell_copy', False)
CONF.set('run', 'run_cell_copy', False)


@flaky(max_runs=3)
Expand Down Expand Up @@ -3043,7 +3040,7 @@ def test_preferences_change_font_regression(main_window, qtbot):

@pytest.mark.skipif(running_in_ci(), reason="Fails on CIs")
@pytest.mark.parametrize('main_window',
[{'spy_config': ('editor', 'run_cell_copy', True)}],
[{'spy_config': ('run', 'run_cell_copy', True)}],
indirect=True)
def test_preferences_empty_shortcut_regression(main_window, qtbot):
"""
Expand Down Expand Up @@ -3519,7 +3516,7 @@ def test_varexp_refresh(main_window, qtbot):
@pytest.mark.skipif(sys.platform == 'darwin' or os.name == 'nt',
reason="Fails on macOS and Windows")
@pytest.mark.parametrize('main_window',
[{'spy_config': ('editor', 'run_cell_copy', False)}],
[{'spy_config': ('run', 'run_cell_copy', False)}],
indirect=True)
@pytest.mark.order(after="test_debug_unsaved_function")
def test_runcell_edge_cases(main_window, qtbot, tmpdir):
Expand Down Expand Up @@ -5426,7 +5423,8 @@ def test_out_runfile_runcell(main_window, qtbot):
CONF.set('run', 'last_used_parameters', run_parameters)

with qtbot.waitSignal(shell.executed):
main_window.editor.run_cell()
qtbot.mouseClick(main_window.run_cell_button,
Qt.LeftButton)
if shown:
assert "]: " + str(num) in control.toPlainText()
else:
Expand Down Expand Up @@ -5952,8 +5950,8 @@ def test_debug_selection(main_window, qtbot):
shell = main_window.ipyconsole.get_current_shellwidget()
control = shell._control
debug_widget = main_window.debugger.get_widget()
debug_selection_action = debug_widget.get_action(
DebuggerToolbarActions.DebugCurrentSelection)
debug_selection_action = main_window.run.get_action(
"run selection in debugger")
continue_action = debug_widget.get_action(
DebuggerWidgetActions.Continue)

Expand Down
20 changes: 11 additions & 9 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@
'pdb_stop_first_line': True,
'breakpoints_panel': True,
}),
('run',
{
'save_all_before_run': True,
'run_cell_copy': False,
}),
('plots',
{
'mute_inline_plotting': True,
Expand Down Expand Up @@ -247,9 +252,6 @@
'show_tab_bar': True,
'show_class_func_dropdown': False,
'max_recent_files': 20,
'save_all_before_run': True,
'focus_to_editor': True,
'run_cell_copy': False,
'onsave_analysis': False,
'autosave_enabled': True,
'autosave_interval': 60,
Expand Down Expand Up @@ -390,7 +392,6 @@
'_/file switcher': 'Ctrl+P',
'_/symbol finder': 'Ctrl+Alt+P',
'_/run': "F5",
'_/run selection': "F9",
'_/configure': "Ctrl+F6",
'_/re-run last script': "F6",
# -- In plugins/init
Expand Down Expand Up @@ -458,8 +459,6 @@
'editor/select all': "Ctrl+A",
# -- In widgets/editor.py
'editor/inspect current object': 'Ctrl+I',
'editor/run selection up to line': 'Shift+F9',
'editor/run selection from line': CTRL + '+F9',
'editor/go to line': 'Ctrl+L',
'editor/go to previous file': CTRL + '+Shift+Tab',
'editor/go to next file': CTRL + '+Tab',
Expand All @@ -485,6 +484,9 @@
'editor/close file 2': "Ctrl+F4",
'editor/run cell': CTRL + '+Return',
'editor/run cell and advance': 'Shift+Return',
'editor/run selection and advance': "F9",
'editor/run selection up to line': 'Shift+F9',
'editor/run selection from line': CTRL + '+F9',
'editor/go to next cell': 'Ctrl+Down',
'editor/go to previous cell': 'Ctrl+Up',
'editor/re-run cell': 'Alt+Return',
Expand Down Expand Up @@ -524,9 +526,9 @@
# ---- In widgets/debugger/framesbrowser.py ----
'debugger/refresh': 'Ctrl+R',
'debugger/search': 'Ctrl+F',
'debugger/debug file': "Ctrl+F5",
'debugger/debug cell': 'Alt+Shift+Return',
'debugger/debug selection': '',
'debugger/run file in debugger': "Ctrl+F5",
'debugger/run cell in debugger': 'Alt+Shift+Return',
'debugger/run selection in debugger': '',
'debugger/next': "Ctrl+F10",
'debugger/continue': "Ctrl+F12",
'debugger/step': "Ctrl+F11",
Expand Down
6 changes: 1 addition & 5 deletions spyder/plugins/console/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ def show_syspath(self):
self.dialog_manager.show(editor)

@Slot()
def run_script(self, filename=None, silent=False, set_focus=False,
args=None):
def run_script(self, filename=None, silent=False, args=None):
"""
Run a Python script.
"""
Expand All @@ -522,9 +521,6 @@ def run_script(self, filename=None, silent=False, set_focus=False,
rbs = remove_backslashes
command = "runfile('%s', args='%s')" % (rbs(filename), rbs(args))

if set_focus:
self.shell.setFocus()

self.change_visibility(True, True)

self.shell.write(command+'\n')
Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/debugger/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

from spyder.plugins.debugger.widgets.main_widget import (
DebuggerWidgetActions, DebuggerToolbarActions, DebuggerBreakpointActions,
DebuggerWidgetActions, DebuggerBreakpointActions,
DebuggerWidgetOptionsMenuSections, DebuggerWidgetMainToolBarSections,
DebuggerWidgetMenus, DebuggerContextMenuSections,
DebuggerContextMenuActions)
Loading

0 comments on commit 8dc6d18

Please sign in to comment.