Skip to content

Preserve adjacent zero-width escape blocks in ANSI text - #2149

Open
FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/ansi-adjacent-zero-width-20261020
Open

FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/ansi-adjacent-zero-width-20261020

Conversation

@FanWu-ai

Copy link
Copy Markdown

Summary

Keep consecutive zero-width escape blocks in ANSI text separate from visible text. The parser currently reads the first character after \002 inside the escape-handling branch, so an immediately following \001 bypasses the block-opening check. Adjacent shell-integration sequences then leak into visible text and affect text width.

Return to the main parsing loop after a block closes. Preserve raw contents, surrounding style, empty blocks, and the existing handling of unfinished blocks.

Validation

  • Clean upstream baseline: 156 tests passed before production changes; all required local lint, format, spelling, type and pre-commit checks passed.
  • Four new tests fail against unchanged source; all pass with the fix.
  • Final full suite: 160 passed on Linux / Python 3.12.14.
  • 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:47
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