Skip to content

Regex highlighting: a [ inside a character class is literal unless it opens a subtraction - #611

Merged
MelbourneDeveloper merged 3 commits into
mainfrom
fix/regex-class-literal-bracket
Nov 19, 2026
Merged

MelbourneDeveloper merged 3 commits into
mainfrom
fix/regex-class-literal-bracket

Conversation

@MelbourneDeveloper

Copy link
Copy Markdown
Collaborator

TLDR

Regex highlighting in C# string literals now ends a character class where .NET does. [a[b]x+ used to colour the whole rest of the pattern as one class.

Details

  • RegexPatternTokens.cs ClassEnd:
    • It counted EVERY [ inside a class as a nested class. In .NET, a [ inside a class is a literal member; only a subtraction, [a-z-[aeiou]], nests.
    • The new OpensSubtraction counts a [ only when an unescaped - comes right before it.
  • Found by the regression review of main against v0.33.0. The code is new since the release, and the bug is cosmetic.

How Do The Automated Tests Prove It Works?

  • RegexHighlightingTests.Pattern_syntax_is_tokenized has two new cases:
    • [a[b]x+ gives [a[b] +: the class ends at its first ], and the literal x stays text.
    • [[]x[a[-[a]]y gives [[] [a[-[a]]: a leading literal [, plus a literal [ next to a real subtraction.
    • Before the fix they failed with Actual: "[a[b]x+" and Actual: "[[]x[a[-[a]]y".
  • The existing cases, including [a-z-[aeiou]] subtraction and [\]] escapes, and the end-to-end literal test still pass: 19/19 with warnings as errors.

… [ inside a class is a literal member unless it opens a -[ subtraction, so [a[b]x no longer paints the rest of the pattern as one class
@MelbourneDeveloper
MelbourneDeveloper enabled auto-merge (squash) November 19, 2026 18:26
MelbourneDeveloper added a commit that referenced this pull request Nov 19, 2026
…unting its own (#612)

## TLDR
The debug Stop suite no longer counts an earlier suite's still-open
test-debug terminal as a ghost of its own. It waits for that terminal to
close, and if one never does, fails with a message that names the leak.

## Details
- Even after #610, Linux `debug-tests` failed on #611 (head `0d31a1f`,
which includes #610). All four Stop variants failed together with `2 !==
1`.
- The pre-cancelled gesture no longer creates a terminal at all, so the
second terminal predates the test.
- The suite just before it, *Debug an MTP test*, ends while its module
is still in its own 30-second wait. That run's terminal closes only once
the run settles, and the Stop test counted every terminal of that name,
globally.
- `debug-test-kit.ts` gains `assertNoTerminalLeft(name, why)`. It waits
up to `DEBUG_SESSION_MS` for no terminal of that name to remain.
- `debug-test-stop-e2e.test.ts` calls it first, so its later "exactly
one terminal" check counts only what the test itself opened. The test
timeout grows by one `DEBUG_TEST_MS` to fit the wait.
- No assertion is removed or loosened. A terminal that never closes
still fails, now at the point that names it.

## How Do The Automated Tests Prove It Works?
- Locally, `debug-test-mtp-e2e` followed by `debug-test-stop-e2e` (CI's
order): 6 passing.
- On this PR's Linux `debug-tests` job, the four Stop variants must
pass. If an earlier suite really leaks a terminal, they fail with `every
earlier debug run closed its terminal once it settled` rather than the
misleading ghost count.
@MelbourneDeveloper
MelbourneDeveloper merged commit 2bfd506 into main Nov 19, 2026
117 of 119 checks passed
@MelbourneDeveloper
MelbourneDeveloper deleted the fix/regex-class-literal-bracket branch November 19, 2026 21:41
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.

1 participant