Skip to content

Remove every matching key binding and invalidate caches - #2151

Open
FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/remove-all-matching-bindings-20261020
Open

FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/remove-all-matching-bindings-20261020

Conversation

@FanWu-ai

Copy link
Copy Markdown

Summary

Remove every matching key binding without skipping adjacent entries. KeyBindings.remove() currently removes from the same list it is iterating, leaving some matching bindings active. This affects both removal by handler and removal by key sequence, including aliases such as enter and c-m.

Iterate over a snapshot in both paths, preserving the original list object, remaining binding order, and existing cache invalidation.

Validation

  • Clean upstream baseline: 156 tests passed before production changes; all required local lint, format, spelling, type and pre-commit checks passed.
  • Eight regression cases fail against unchanged source; controls cover interleaved matches and a missing handler.
  • Final full suite: 171 passed on Linux / Python 3.12.14.
  • Coverage includes both lookup caches, merged registries, multiple keys sharing a handler, key aliases, and dispatch after removal.
  • Ruff lint/format, typos, strict mypy for win32/linux/darwin, all 12 configured pre-commit hooks, sdist/wheel builds, and git diff --check passed.

This leaves the unrelated unknown-key error addressed by #2043 unchanged. 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:51
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