Skip to content

Commit 54298e2

Browse files
committed
don't throw with invalid regexes, microsoft#51109
1 parent 50b7b58 commit 54298e2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/vs/platform/contextkey/common/contextkey.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ export class ContextKeyRegexExpr implements ContextKeyExpr {
401401
}
402402

403403
public serialize(): string {
404-
return `${this.key} =~ /${this.regexp ? this.regexp.source : '<invalid>'}/${this.regexp.ignoreCase ? 'i' : ''}`;
404+
const value = this.regexp
405+
? `/${this.regexp.source}/${this.regexp.ignoreCase ? 'i' : ''}`
406+
: '/invalid/';
407+
return `${this.key} =~ ${value}`;
405408
}
406409

407410
public keys(): string[] {

0 commit comments

Comments
 (0)