Skip to content

fix: opening bracket insertion fails after autocomplete#3

Merged
eitsupi merged 1 commit intomainfrom
fix/parenthesis-insertion-after-autocomplete
Jan 28, 2026
Merged

fix: opening bracket insertion fails after autocomplete#3
eitsupi merged 1 commit intomainfrom
fix/parenthesis-insertion-after-autocomplete

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Jan 28, 2026

No description provided.

Skip-over rules incorrectly matched opening bracket events because both
opening `(` and closing `)` bracket rules matched `InsertString("()")`.

Fix by:
- Binding closing brackets to `InsertChar(close_char)` in keybindings
- Updating skip-over rules to match `InsertChar` for brackets

This distinguishes opening bracket key presses (InsertString + MoveLeft)
from closing bracket key presses (InsertChar).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi marked this pull request as ready for review January 28, 2026 15:52
Copilot AI review requested due to automatic review settings January 28, 2026 15:52
@eitsupi eitsupi merged commit af69bc8 into main Jan 28, 2026
3 of 4 checks passed
@eitsupi eitsupi deleted the fix/parenthesis-insertion-after-autocomplete branch January 28, 2026 15:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where pressing an opening bracket key after autocomplete would incorrectly trigger skip-over behavior instead of inserting a bracket pair. The root cause was that skip-over rules were matching the opening bracket's InsertString(pair) + MoveLeft event instead of only matching the closing bracket's InsertChar event.

Changes:

  • Modified skip-over rules to distinguish between opening and closing bracket events by matching InsertChar for brackets and InsertString + MoveLeft for quotes
  • Updated keybindings to bind closing bracket characters to InsertChar events
  • Added comprehensive tests to verify the fix and prevent regression

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/arf-console/src/editor/mode.rs Refactored create_skip_over_rules() to separate bracket and quote handling, and added extensive tests for the fix
crates/arf-console/src/editor/keybindings.rs Updated add_auto_match_keybindings() to bind closing brackets to InsertChar events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let rules = create_skip_over_rules();

// First 3 rules are for brackets: `)`, `]`, `}`
for (i, close_char) in [')' , ']', '}'].iter().enumerate() {
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space before comma after ')' character. Should be [')' ,[')',

Copilot uses AI. Check for mistakes.
eitsupi added a commit that referenced this pull request Feb 11, 2026
- Fix fd leak when PENDING_TERMIOS_RESTORE mutex is poisoned after
  successful tcgetattr (finding #2)
- Restore comment explaining intentional if guard in write_empty_password
  for release builds where debug_assert is stripped (finding #3)
- Document that rpassword's internal fd leaks on longjmp as a known
  minor limitation (finding #1)
- Note UTF-8 restriction from rpassword vs previous raw bytes (finding #4)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

2 participants