Skip to content

Extend goto_matching_bracket to work inside bracket bodies#1351

Merged
sinelaw merged 2 commits intomasterfrom
claude/improve-bracket-matching-FhXB5
Mar 24, 2026
Merged

Extend goto_matching_bracket to work inside bracket bodies#1351
sinelaw merged 2 commits intomasterfrom
claude/improve-bracket-matching-FhXB5

Conversation

@sinelaw
Copy link
Copy Markdown
Owner

@sinelaw sinelaw commented Mar 24, 2026

Summary

  • Fixes goto_matching_bracket should work when inside bracket body. #1258: goto_matching_bracket now works when the cursor is inside bracket-enclosed content, not just when directly on a bracket character
  • When cursor is not on a bracket, searches backward for the nearest enclosing opening bracket, then jumps to its matching closing bracket
  • Matches behavior of VSCode and JetBrains IDEs

Test plan

  • Added e2e tests for existing behavior (cursor on opening/closing bracket)
  • Added e2e tests for new behavior: cursor inside (), {}, [], and nested brackets
  • All 7 tests pass
  • cargo fmt clean

https://claude.ai/code/session_01BLdfcnQNWwvqE2TBwJFytr

claude added 2 commits March 24, 2026 20:01
When the cursor is not directly on a bracket character, search backward
to find the nearest enclosing opening bracket, then jump to its matching
closing bracket. This matches the behavior of VSCode and JetBrains IDEs.

https://claude.ai/code/session_01BLdfcnQNWwvqE2TBwJFytr
Reuse the existing 1MB limit from bracket_highlight_overlay for all
three search loops in goto_matching_bracket (backward enclosure search,
forward match, backward match) to prevent hangs on huge files.

https://claude.ai/code/session_01BLdfcnQNWwvqE2TBwJFytr
@sinelaw sinelaw merged commit d764eac into master Mar 24, 2026
8 checks passed
@sinelaw sinelaw deleted the claude/improve-bracket-matching-FhXB5 branch March 24, 2026 20:33
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.

goto_matching_bracket should work when inside bracket body.

2 participants