Context key scanner rejects the d and v regex flags in when clauses
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
### Bug description
The context key expression scanner whitelists which regex flags may follow a regex literal in a `when` clause (`src/vs/platform/contextkey/common/scanner.ts`, `_regexFlags`). The set is
```ts
['i', 'g', 's', 'm', 'y', 'u']
```
which is missing the two newer ECMAScript flags: `d` (hasIndices) and `v` (unicodeSets). Both are valid in the engines VS Code ships on, but a when clause that uses them fails to lex: the trailing flag character is not consumed as part of the regex token, becomes a separate `Str` token, the parser then reports "Expected: REGEX", and `ContextKeyExpr.deserialize` returns `undefined` for a perfectly legal clause.
Example: an extension manifest containing
```json
"when": "a =~ /x/d"
```
silently evaluates to never-match today.
### Steps to reproduce
1. Add a keybinding or view with `"when": "editorTextFocus =~ /x/d"` (any regex using the `d` or `v` flag).
2. Observe the clause never activates; enabling context key tracing shows it deserialized to undefined.
Flags from the whitelist (`/x/i`, `/x/gm`) work as expected.
### Expected behavior
All ECMAScript regex flags accepted by the runtime should lex, parse and deserialize, so `/x/d` and `/x/v` clauses behave like `/x/i`.
### Version tested
Commit `77f86f3d3a0` on `main`. Reproduced at the unit level: scanning `'foo =~ /zee/d'` yields a trailing `Str 'd'` token instead of a single `RegexStr '/zee/d'`. A fix plus scanner tests and an end-to-end deserialize test is ready.
Contributor guide
Assessment
This issue has not been assessed yet.