Skip to content

Fix event dispatch when handlers modify subscriptions - #2153

Open
FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/event-handler-snapshot-20261021
Open

FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/event-handler-snapshot-20261021

Conversation

@FanWu-ai

Copy link
Copy Markdown

Summary

Dispatch events over a snapshot of registered handlers. A callback that removes itself no longer skips the following callback, and callbacks added while dispatching are deferred until the next firing. Nested dispatch uses its own fresh snapshot; exception propagation is unchanged.

Validation

  • Seven regression cases, including Buffer.on_text_changed integration: five fail on pristine source and two controls pass.
  • Pristine complete suite: 156 passed. Final complete suite: 163 passed (CPython 3.12.14, Linux).
  • All 12 configured pre-commit hooks pass, plus standalone typos, Ruff lint/format and strict Mypy for win32/linux/darwin.
  • Sdist/wheel build and git diff --check pass.
  • Independent AI review approved the patch and reran all 163 tests.

AI-assisted implementation and review; no human review is claimed. Hosted CI is separate and not yet verified.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 20, 2026 21:42
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