Skip to content

Evaluate global key binding filters dynamically - #2150

Open
FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/dynamic-global-bindings-20261020
Open

FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/dynamic-global-bindings-20261020

Conversation

@FanWu-ai

Copy link
Copy Markdown

Summary

Evaluate dynamic is_global filters when key bindings are used. GlobalOnlyKeyBindings currently evaluates the filter only while building its cached registry; changing the condition afterward can leave an unfocused control's shortcut permanently enabled or disabled.

Preserve the condition in each copied binding's activation filter, together with its existing filter. Keep eager handling, macro recording, save-before callbacks, and global metadata intact, and continue omitting statically non-global bindings.

Validation

  • Clean upstream baseline: 156 tests passed before production changes; all required local lint, format, spelling, type and pre-commit checks passed.
  • Five regression cases fail against unchanged source, including a real Application with an unfocused control.
  • Final full suite: 162 passed on Linux / Python 3.12.14.
  • Coverage includes both initial condition values, repeated enable/disable transitions, exact and prefix lookups, merged registries, the existing activation filter, and binding attributes.
  • Ruff lint/format, typos, strict mypy for win32/linux/darwin, all 12 configured pre-commit hooks, sdist/wheel builds, and git diff --check passed.

Platform-specific mypy checks are static checks, not native OS test runs. Hosted CI status is separate from these local results.

Prepared and tested with OpenAI Codex assistance. No human review is claimed.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 19, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant