The Manage Custom Patterns command lets users define regex patterns with a severity and category, but there is no way to test a new pattern against sample input before saving it. Developers will write patterns that either never match or match everything, and only discover this at paste time.
Problem
Writing a correct regex is non-trivial, especially for:
- Patterns with lookaheads / lookbehinds
- Patterns that need to avoid matching substrings of larger tokens
- Patterns with catastrophic backtracking potential (e.g.
(a+)+ style constructs)
Currently a user writes a regex, saves it, pastes some test content, sees nothing happen (or sees everything flagged), and has no idea whether their pattern is wrong or their test input is wrong. The only debugging path is editing settings.json directly.
Proposed solution
Add a "Test pattern" panel to the custom patterns UI.
Scope:
- A text input field labelled "Test input" in the add/edit pattern form
- Live match/no-match indicator as the user types (debounced, ~200ms)
- Highlight the matched substring within the test input
- Warn if:
- The pattern matches an empty string
- The pattern has no anchors and could match anything (e.g.
.*)
- Basic catastrophic backtracking patterns are detected (e.g. nested quantifiers on the same character class)
- The test field is local to the UI session — it is not saved
Example UI state:
Pattern regex: MYCOMPANY_[a-zA-Z0-9]{32}
Test input: MYCOMPANY_aBcDeFgHiJkLmNoPqRsTuVwXyZ12
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Match found ✓
Acceptance criteria
The
Manage Custom Patternscommand lets users define regex patterns with a severity and category, but there is no way to test a new pattern against sample input before saving it. Developers will write patterns that either never match or match everything, and only discover this at paste time.Problem
Writing a correct regex is non-trivial, especially for:
(a+)+style constructs)Currently a user writes a regex, saves it, pastes some test content, sees nothing happen (or sees everything flagged), and has no idea whether their pattern is wrong or their test input is wrong. The only debugging path is editing
settings.jsondirectly.Proposed solution
Add a "Test pattern" panel to the custom patterns UI.
Scope:
.*)Example UI state:
Acceptance criteria