Skip to content

Add configurable auto-insert pairing - #1098

Open
saberoueslati wants to merge 1 commit into
dail8859:masterfrom
saberoueslati:feature/1085-braces-autocompletion
Open

Add configurable auto-insert pairing#1098
saberoueslati wants to merge 1 commit into
dail8859:masterfrom
saberoueslati:feature/1085-braces-autocompletion

Conversation

@saberoueslati

Copy link
Copy Markdown
Contributor

Description

Fixes #1085

This PR adds configurable automatic insertion of matching delimiters for parentheses, square brackets, curly braces, single quotes, and double quotes.

The feature creates and tracks generated closers so users can type through them, remove an empty generated pair with Backspace, and retain the expected behavior through Undo and Redo. The settings apply immediately to already-open editors.

HTML/XML closing-tag completion is now configurable through the same Auto-Insert preferences section. It remains enabled by default to preserve the existing behavior and now works in both HTML and XML documents.

Changes Made

  • Added persistent Auto-Insert settings for:
    • Parentheses ()
    • Square brackets []
    • Curly braces {}
    • Single quotes ''
    • Double quotes ""
    • HTML/XML closing tags
  • Added Auto-Insert controls to Preferences.
  • Added AutoInsertDecorator to handle pair insertion, generated-closer overtyping, paired Backspace, and Undo/Redo tracking.
  • Ignore auto-repeat input, modifier shortcuts, escaped quotes, non-empty selections, virtual-space carets, and non-stream selections.
  • Apply Auto-Insert preference changes immediately to all open editors.
  • Made HTML/XML closing-tag completion independently configurable.
  • Enabled closing-tag completion for both HTML and XML language modes.
  • Preserved HTML/XML closing-tag completion as enabled by default.

Testing

Manual test plan :

TestPlan-AutoInsert.md

Coverage includes:

  • Auto-Insert preference visibility, defaults, independence, live updates, and persistence across restart.
  • Pair insertion for parentheses, square brackets, curly braces, single quotes, and double quotes.
  • Disabled delimiter behavior, nested and adjacent pairs, and delimiter insertion around UTF-8 text.
  • Generated-closer overtyping, tracking after document edits, and preventing ordinary closers from being skipped.
  • Paired Backspace behavior for generated pairs and normal Backspace behavior for modified or ordinary pairs.
  • Undo/Redo behavior for pair insertion, closer overtyping, and paired Backspace.
  • Existing surround-selection behavior and interaction with empty and non-empty selections.
  • Input safeguards for auto-repeat, escaped quotes, modifier shortcuts, rectangular selections, and pasted text.
  • HTML and XML closing-tag completion, preference updates in open editors, language switching, attributes, self-closing tags, void elements, comments, malformed tags, embedded JavaScript, and tag-length boundaries.

Video of basic manual test below :

Screencast.from.2026-07-25.22-39-40.webm

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.

Braces autocompletion

1 participant