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 14 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.
  • Change context of Switcher plugin shortcuts to be _, i.e. global (before their context was switcher but that made little sense).

Issue(s) Resolved

Fixes #23072
Fixes #22741
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
@ccordoba12 ccordoba12 force-pushed the issue-22516 branch 7 times, most recently from 251ca02 to 8b3fe55 Compare November 21, 2024 17:15
@ccordoba12 ccordoba12 closed this Nov 21, 2024
@ccordoba12 ccordoba12 reopened this Nov 21, 2024
@ccordoba12 ccordoba12 marked this pull request as ready for review November 21, 2024 23:42
@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

The current docstrings were not easy to understand.
- 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.
Also, add inline typing for several attributes of ConfigurationManager
and remove associated comments.
@ccordoba12
Copy link
Member Author

ccordoba12 commented Nov 25, 2024

However, when you modify a shortcut and then trigger a reset from the preferences page, the reset changes are not being honored inmediatly

Thanks for checking that @dalthviz! It should be fixed now.

I also took the opportunity to change the context of the Switcher shortcut actions to be _ because they are actually global shortcuts (the context was switcher).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants