Skip to content

feat: Add filter_keybinding to KeyBindingRegistry#212

Merged
tlambert03 merged 10 commits intopyapp-kit:mainfrom
lucyleeow:kb_filter
Jul 19, 2024
Merged

feat: Add filter_keybinding to KeyBindingRegistry#212
tlambert03 merged 10 commits intopyapp-kit:mainfrom
lucyleeow:kb_filter

Conversation

@lucyleeow
Copy link
Copy Markdown
Collaborator

@lucyleeow lucyleeow commented Jul 11, 2024

closes #206

Adds a filter_keybinding (not 100% on name) attr to KeyBindingRegistry, which takes Callable[[KeyBinding], str] - if str is empty the keybinding is valid otherwise error message str should be returned.

Just a start, happy to take any feedback.

Will update docs once code ready.

@lucyleeow lucyleeow changed the title ENH Add filter_keybinding to KeyBindingRegistry feat: Add filter_keybinding to KeyBindingRegistry Jul 11, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0e801a9) to head (645062c).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #212   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           31        31           
  Lines         1814      1833   +19     
=========================================
+ Hits          1814      1833   +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Member

@tlambert03 tlambert03 left a comment

Choose a reason for hiding this comment

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

looks good, but we need to catch the new possible ValueError inside of the for loop in register_action_keybindings

            if d := self.register_keybinding_rule(action.id, _keyb):
                disposers.append(d)

otherwise one bad keybinding will ruin the whole batch (and add a test for that)

@lucyleeow
Copy link
Copy Markdown
Collaborator Author

Thanks @tlambert03, I think changes are made. I will look at any doc updates once code okay.

Copy link
Copy Markdown
Member

@tlambert03 tlambert03 left a comment

Choose a reason for hiding this comment

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

thanks @lucyleeow, perfect 👌

@tlambert03 tlambert03 merged commit 3cf855e into pyapp-kit:main Jul 19, 2024
@tlambert03 tlambert03 added the enhancement New feature or request label Jul 19, 2024
@lucyleeow lucyleeow deleted the kb_filter branch July 19, 2024 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

Allow 'filter' option in keybinding registry

2 participants