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
['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
silently evaluates to never-match today.
Steps to reproduce
- Add a keybinding or view with
"when": "editorTextFocus =~ /x/d" (any regex using the d or v flag).
- 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.
Bug description
The context key expression scanner whitelists which regex flags may follow a regex literal in a
whenclause (src/vs/platform/contextkey/common/scanner.ts,_regexFlags). The set iswhich is missing the two newer ECMAScript flags:
d(hasIndices) andv(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 separateStrtoken, the parser then reports "Expected: REGEX", andContextKeyExpr.deserializereturnsundefinedfor a perfectly legal clause.Example: an extension manifest containing
silently evaluates to never-match today.
Steps to reproduce
"when": "editorTextFocus =~ /x/d"(any regex using thedorvflag).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/dand/x/vclauses behave like/x/i.Version tested
Commit
77f86f3d3a0onmain. Reproduced at the unit level: scanning'foo =~ /zee/d'yields a trailingStr 'd'token instead of a singleRegexStr '/zee/d'. A fix plus scanner tests and an end-to-end deserialize test is ready.