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: Fix shortcuts for several Run and Debugger actions #22230

Merged
merged 10 commits into from
Jul 10, 2024

Conversation

ccordoba12
Copy link
Member

@ccordoba12 ccordoba12 commented Jul 4, 2024

Description of Changes

  • Make shortcuts for Run cell, Run cell and advance and other Run actions, as well as next, continue and other Debugger actions, local to the Editor again.
  • Add a new SpyderShortcutsMixin to spyder.api.shortcuts and use it to simplify the way shortcuts are registered for widgets. That's necessary when a widget is not a direct child of the one where an action with shortcut was created (e.g. the EditorStack with respect to EditorMainWidget).
  • Add Ctrl+Shift+D as the new shortcut to go to the Debugger (and remove that shortcut for the Online Help).
  • Change context for array builder shortcuts from array_builder to editor. That follows the convention already used in the IPython console.
  • Fix width of the Debugger breakpoints table at startup (I noticed this problem while testing these changes).
  • Remove old code to register shortcuts for widgets.

Note

There's still a limitation (also present in Spyder 5) with shortcuts registered for widgets: they are not updated after a change in Preferences. I tried to fix that as part of this PR but it requires several changes to the way shortcut options are tracked and notified, so I prefer to leave it for a follow-up one.

Issue(s) Resolved

Fixes #21129.

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: @ccordoba12

- Improve how shortcuts are registered in widgets.
- Use that mixin in other places where we need to get/set shortcuts.
- Remove code related to shortcuts from SpyderConfigurationAccessor
- Remove unnecessary code related to the old way of registering
shortcuts for widgets.
@pep8speaks
Copy link

pep8speaks commented Jul 4, 2024

Hello @ccordoba12! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 75:1: E402 module level import not at top of file

Comment last updated at 2024-07-06 15:41:45 UTC

@ccordoba12 ccordoba12 changed the title PR: Fix shortcuts for run and debugger actions PR: Fix shortcuts for several Run and Debugger actions Jul 4, 2024
- Also make run cell and selection in debugger shortcuts work only for
the editor.
- And set a new shortcut for run selection in debugger.
Also, remove unnecessary calls to shortcuts.apply_shortcuts()
That was computed correctly if the Debugger is not focused at startup.
@ccordoba12
Copy link
Member Author

@dalthviz, this is ready for review.

@dalthviz
Copy link
Member

dalthviz commented Jul 5, 2024

Gave this an initial check and seems like there are missing changes to cover shortcuts for plugins like Code Analysis and Profiler? With this I'm unable to trigger via shortcuts the profiler (F10) or code analysis (F8) which are working when running from master

- That's necessary to create EditorMainWindow's independently of the
Editor (e.g. for testing).
- Also, fix a test related to shortcuts and add a clarifying comment.
@ccordoba12
Copy link
Member Author

Gave this an initial check and seems like there are missing changes to cover shortcuts for plugins like Code Analysis and Profiler?

That's right, I didn't check those shortcuts. But they should be working now, so please test again.

@dalthviz
Copy link
Member

dalthviz commented Jul 7, 2024

Note: Could this be related with #14403 ?

@ccordoba12
Copy link
Member Author

Yep, that's mostly the same problem. But in the case of the Editor, the thing is that EditorStack and CodeEditor are several layers below EditorMainWidget, so it's not easy to propagate shortcuts declared on the latter to the first.

And we can't create Run cell in EditorStack, for instance, because we can have any number of EditorStacks. So, the action corresponding to Run cell won't be unique.

It's a tricky problem that we have to think better. For now I think what I did is just a stopgap solution.

Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ccordoba12 ! Checked locally and seems like things are working, so this LGTM 👍

@dalthviz dalthviz merged commit ad4827e into spyder-ide:master Jul 10, 2024
14 checks passed
@ccordoba12 ccordoba12 deleted the fix-run-debugger-shortcuts branch July 10, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spyder 6.0.0a1 - New line (ctrl-enter) in console runs cell instead
3 participants