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: Restore widget shortcuts to Preferences and allow to change them on the fly (Shortcuts) #23024

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ccordoba12
Copy link
Member

@ccordoba12 ccordoba12 commented Nov 19, 2024

Description of Changes

  • Those shortcuts were not shown in Spyder 6, as reported by several users.
  • That was a regression introduced by PR: Fix shortcuts for several Run and Debugger actions #22230, which unfortunately we overlooked.
  • This also fixes an important usability issue: changing those shortcuts didn't have an immediate effect (like all other shortcuts), but required an app restart. That issue was also present in Spyder 5 and it was very counterintuitive. Now those shortcuts will be updated on the fly.
  • Introduce a new ShortcutData dataclass to represent shortcut data internally and work more easily with it.

Issue(s) Resolved

Fixes #22516

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

@ccordoba12 ccordoba12 added this to the v6.0.3 milestone Nov 19, 2024
@ccordoba12 ccordoba12 self-assigned this Nov 19, 2024
@ccordoba12 ccordoba12 marked this pull request as draft November 19, 2024 03:17
The current docstrings were not easy to understand.
@ccordoba12 ccordoba12 force-pushed the issue-22516 branch 6 times, most recently from bbbc620 to 251ca02 Compare November 20, 2024 21:27
- The previous solution, which used tuples to collect those data, was
easy to break, because it required to put data in the right order; and
undocumented, because it was unclear what kind of data had to be added
in the tuple elements.
- Those limitations made difficult to reason about shortcuts-related
code.
- Before we only allowed class methods decorated with on_conf_change to
do that.
- But that's too limited if we need to use regular functions to observe
an option. And that's precisely what this new method allows us to do.
This is necessary to add observers for specific shortcuts.
- That allows those shortcuts to be updated on the fly when they are
changed in Preferences or directly with set_conf.
- Also, fix inheritance of classes that inherit from
SpyderShortcutsMixin to accomodate this change.
That was introducing an error in test_shortcut_for_widget_is_updated
when run on CI due to the incorrectly named section.
This is to have feature parity of kwargs with the other methods of
SpyderShortcutsMixin.
@ccordoba12
Copy link
Member Author

@dalthviz, this is ready for review. Please check that:

  • Shortcuts registered with register_shortcut_for_widget are shown in Preferences.
  • Changing those shortcuts works immediately (i.e. without a restart) in their respective widgets.

@dalthviz
Copy link
Member

Gave this an initial check and seems like manually changing shortcuts is working and also shortcuts like duplicate line down are being displayed over the shortcuts preferences page 👍 However, when you modify a shortcut and then trigger a reset from the preferences page, the reset changes are not being honored inmediatly:

widget_shortcuts

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.

Many shortcuts not showing in Preferences
2 participants