What happens
reraise_exceptions (default false) is documented as suppressing console errors from rule matching unless explicitly enabled. Two of the three rule-matching code paths honor it correctly (glob_matches and function_matches in ApplySyntax.py both catch exceptions and check self.reraise_exceptions). The third path, plain regex rule matching (regexp_matches, used for first_line/interpreter/file_path/contains rules), has no exception handling at all — a malformed pattern raises re.error directly from re.match/re.search, uncaught, regardless of the setting.
Repro steps
- Add a rule to ApplySyntax's User settings under
"syntaxes":
{
"name": "BadRegexTest",
"syntax": "Packages/Text/Plain text.tmLanguage",
"rules": [{"first_line": "(unclosed["}]
}
- Open (or save) any file — this rule has no
extensions filter so it's evaluated for every file.
- The console shows an uncaught
re.error from regexp_matches, even with reraise_exceptions left at its default false.
Suggested fix
Wrap the re.match/re.search call in regexp_matches in the same try/except + reraise_exceptions check already used in glob_matches and function_matches.
Found via source review + a live test that was interrupted by an unrelated local environment issue before the exact traceback could be captured on this machine, but the code path is unambiguous — happy to help verify further if useful.
What happens
reraise_exceptions(defaultfalse) is documented as suppressing console errors from rule matching unless explicitly enabled. Two of the three rule-matching code paths honor it correctly (glob_matchesandfunction_matchesinApplySyntax.pyboth catch exceptions and checkself.reraise_exceptions). The third path, plain regex rule matching (regexp_matches, used forfirst_line/interpreter/file_path/containsrules), has no exception handling at all — a malformed pattern raisesre.errordirectly fromre.match/re.search, uncaught, regardless of the setting.Repro steps
"syntaxes":{ "name": "BadRegexTest", "syntax": "Packages/Text/Plain text.tmLanguage", "rules": [{"first_line": "(unclosed["}] }extensionsfilter so it's evaluated for every file.re.errorfromregexp_matches, even withreraise_exceptionsleft at its defaultfalse.Suggested fix
Wrap the
re.match/re.searchcall inregexp_matchesin the same try/except +reraise_exceptionscheck already used inglob_matchesandfunction_matches.Found via source review + a live test that was interrupted by an unrelated local environment issue before the exact traceback could be captured on this machine, but the code path is unambiguous — happy to help verify further if useful.