Avoid pairing brackets in comments and strings

JO
36m ago
+610-11

Typing an opening bracket inside a comment or string currently inserts an unwanted closer. For example, typing ( after // note produces // 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:

  • Nine C++ reproduction cases failed before the fix and pass afterward.
  • Focused editor tests: 91 passed, no failures or skips.
  • ./scripts/test.sh completed successfully; the Node/browser suite reported 1,165 passed, no failures or skips.
  • Git hook suite: 49 checks passed.
  • Prettier, ESLint, and git diff --check passed.
  • cargo-audit, actionlint, and ruff were unavailable and skipped; the hook run also skipped commentflow.

Closes #307


Summary by cubic

Typing an opening bracket inside a comment or string no longer inserts a matching closer. For example, typing ( after // note stays // 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.

Dependencies

  • Upgrades rustls to 0.23.46 so the security audit passes.

Closes #307