Repository navigation
Avoid pairing brackets in comments and strings - #308
Open
Jonathas2127 wants to merge 3 commits into
Open
Jonathas2127 wants to merge 3 commits into
Jonathas2127 wants to merge 3 commits into
Conversation
Bracket auto-close inserts unwanted delimiters in comments and strings. Use the shared lexical context while preserving native insertion and selection wrapping. Keep pairing independent of syntax highlighting.
jserv
reviewed
Oct 14, 2026
jserv
reviewed
Oct 14, 2026
Literal-aware insertion must not let Backspace delete existing closers. Keep bracket edits consistent and preserve f-string expressions when parsing is unavailable. Verify parser loading through editor behavior.
Unfinished f-strings can produce a syntax tree with parsing errors. Match the tokenizer's fallback condition when a tree contains errors. Preserve bracket insertion, deletion, and type-over behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Typing an opening bracket inside a comment or string currently inserts an unwanted closer. For example, typing
(after// noteproduces// note (). This change inserts only the typed character in those contexts while retaining pairing in code and wrapping selected text.The pairing handler reuses the existing tokenizer to classify the inserted character, including at end-of-buffer and in unfinished literals. Parser preparation also runs when Auto-close is enabled independently of highlighting and indentation, with the existing scanner handling parser unavailability.
Validation:
./scripts/test.shcompleted successfully; the Node/browser suite reported 1,165 passed, no failures or skips.git diff --checkpassed.cargo-audit,actionlint, andruffwere unavailable and skipped; the hook run also skippedcommentflow.Closes #307
Summary by cubic
Typing an opening bracket inside a comment or string no longer inserts a matching closer. For example, typing
(after// notestays// note (instead of// note (), while pairing in code, wrapping selected text, and f-string interpolation expressions all still work. This holds even when the parser is unavailable or returns an error tree for unfinished f-strings. Typing a closer or pressing Backspace inside a literal now also leaves the text to native editing, so existing closers aren't skipped or deleted.The change reuses the existing tokenizer to classify the inserted character, including at end-of-buffer and in unfinished literals. Python f-strings keep pairing inside expressions while ordinary strings stay literal, and unknown languages keep the previous behavior. Parser preparation now also runs when auto-close is enabled independently of highlighting and indentation.
Closes #307
Written for commit 8fe829b. Summary will update on new commits.