Skip to content

Identify bracket cursor highlighting in source coordinates - #2147

Open
FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/bracket-source-coordinates-20261019
Open

FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix/bracket-source-coordinates-20261019

Conversation

@FanWu-ai

Copy link
Copy Markdown

Problem

HighlightMatchingBracketProcessor compares a transformed display column with the original cursor column, without checking the source row. For (\n), both brackets receive the cursor style when the cursor is on either bracket. When a previous processor inserts a prefix, the bracket under the cursor instead receives the other-bracket style.

Change

Determine whether a bracket is under the cursor using its source row and column, before mapping its column into display coordinates.

Regression coverage

Test the cursor on either bracket of a multiline pair, both without a prefix and with a source-to-display offset. Also preserve the existing other-bracket style when the cursor is immediately after the closing bracket, for single-line and multiline pairs.

AI-assisted implementation; the patch and test results were reviewed.

Validation

  • Unmodified base: 156 tests passed; project lint, formatting, spelling, all three strict mypy platform checks and all pre-commit hooks passed.
  • Regression against unmodified HighlightMatchingBracketProcessor: 4 failed, 4 passed.
  • Fixed tree: 164 tests passed; ruff check, ruff format --check, typos, mypy --strict for win32/linux/darwin, all 12 prek hooks, and git diff --check passed.
  • Independently reviewed with additional focused checks.
  • Local runtime: Python 3.12.14 on Linux. Hosted CI has not yet run for this PR.

Commands run successfully against the final tree:

.venv/bin/coverage run -m pytest tests/
.venv/bin/ruff check .
.venv/bin/ruff format --check .
.venv/bin/typos .
.venv/bin/mypy --strict src/ --platform win32
.venv/bin/mypy --strict src/ --platform linux
.venv/bin/mypy --strict src/ --platform darwin
PREK_HOME=/tmp/prek-c .venv/bin/prek run --all-files
git diff --check

Packaging validation: .venv/bin/python -m build passed in an isolated build environment and produced both the sdist and wheel. Setuptools emitted deprecation warnings concerning upstream license classifiers; the build completed successfully.

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