Skip to content

fix(textmate): read indentation patterns as JavaScript - #57

Merged
BartvHelvert merged 2 commits into
masterfrom
fix/textmate-indent-regex
Nov 4, 2026
Merged

BartvHelvert merged 2 commits into
masterfrom
fix/textmate-indent-regex

Conversation

@BartvHelvert

Copy link
Copy Markdown
Owner

What this changes

The bundled TextMate plugin's TextMateLineIndentProvider compiles a language configuration's indentationRules and onEnterRules with java.util.regex. VS Code compiles them as JavaScript regexes. Go's increaseIndentPattern has a bare {, which JavaScript reads as a literal and Java rejects with "Illegal repetition". Every Enter in a .go file logged a SEVERE error, and the new line wasn't indented.

CodeBridgeTextMateLineIndent is now registered as the first lineIndentProvider and takes over line indentation for TextMate files. It applies the same rules as the platform's, with two differences:

  • Each pattern goes through JavaScriptRegex, which rewrites the JavaScript-only syntax that turns up in patterns into the Java equivalent: a literal {, [ and && inside a class, [], [^], \v, a lone \0, and identity escapes like \y.
  • The line is searched for each pattern, as VS Code's RegExp.test does, instead of the pattern being matched against the whole line.

A pattern that still doesn't compile is logged once as a warning and ignored. The platform gap is recorded in docs/platform-limitations.md as a request to fix it in TextMate.

Fixes #56

How it was tested

  • JavaScriptRegexTest (new, 5 tests) covers Go's real increaseIndentPattern, quantifiers versus literal braces, class contents, empty classes, and escapes.
  • The test extension's increaseIndentPattern now has a bare {, as Go's does. CodeBridgeTextMateEnterBetweenBracesTest registers the new provider and checks that Enter after if ready { indents the next line and Enter after a plain line doesn't.
  • :textmate.backend:test passed (10 tests).
  • Not run: the full test suite, the split-mode UI test, and a manual check with golang.go in a sandbox IDE.

Checklist

  • Nothing is special-cased for one extension.
  • A new feature has a UI test. Bug fix, not a feature.
  • No internal, override-only, obsolete or deprecated platform API.
  • docs/ is updated where behaviour changed, docs/status.md especially.
  • Third-party material keeps its notice and is listed in NOTICE.md. None added.

TextMate's line indent provider compiles language-configuration
patterns with java.util.regex. Go's increaseIndentPattern has a bare
"{", which JavaScript reads as a literal and Java rejects, so every
Enter in a .go file logged a SEVERE and the new line wasn't indented.

Take over line indentation for TextMate files. The rules stay the
platform's, but each pattern is rewritten into the Java regex that
reads the same and searched for in the line, as VS Code's RegExp.test
does. The gap is recorded in docs/platform-limitations.md.

Refs #56
CodeStyleSettings.getIndentOptionsByFile is internal, which failed verifyPlugin.
@BartvHelvert
BartvHelvert force-pushed the fix/textmate-indent-regex branch from 3dcb501 to bbf7a02 Compare November 4, 2026 23:24
@BartvHelvert
BartvHelvert merged commit bf505c3 into master Nov 4, 2026
5 of 6 checks passed
@BartvHelvert
BartvHelvert deleted the fix/textmate-indent-regex branch November 4, 2026 23:25
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.

Enter in Go files fails on JavaScript-only indentation patterns

1 participant