-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: master
Are you sure you want to change the base?
Conversation
251ca02
to
8b3fe55
Compare
8b3fe55
to
b18dc1a
Compare
@dalthviz, this is ready for review. Please check that:
|
Gave this an initial check and seems like manually changing shortcuts is working and also shortcuts like |
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.
b18dc1a
to
1f336d9
Compare
- 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.
1f336d9
to
b8d84e8
Compare
Also, remove some extra valid contexts that are not necessary anymore.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ccordoba12 ! Gave another local check to the reset shortcuts to default values and seems like things are working as expected now. Left a couple of questions and couple of suggestions like using an f-string at somepoint and an idea to extend a test but other than that this LGTM 👍
@@ -703,7 +723,12 @@ def set_shortcut(self, context, name, keystr, plugin_name=None): | |||
Context must be either '_' for global or the name of a plugin. | |||
""" | |||
config = self._get_shortcut_config(context, plugin_name) | |||
config.set('shortcuts', context + '/' + name, keystr) | |||
option = context + "/" + name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be an f-string , no?
|
||
# Check previous shortcut doesn't work | ||
qtbot.keyClick(editor, Qt.Key_Down, modifier=Qt.AltModifier) | ||
assert editor.toPlainText() == "bb\ncc\naa\ndd\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be possible to add as part of this test or in a different test a full config restart and check that the original shortcut works?
'find_replace', | ||
'switcher' | ||
] | ||
EXTRA_VALID_SHORTCUT_CONTEXTS = ['_', 'find_replace'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess those other contexts were previously removed and are not needed anymore, right?
Description of Changes
ShortcutData
dataclass to represent shortcut data internally and work more easily with it._
, i.e. global (before their context wasswitcher
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