Skip to content

Commit 5c55541

Browse files
authored
ulugbekna/remove console warns (microsoft#175239)
* context keys: old parser: remove console.warn's * context keys: new parser: remove console.warn's
1 parent d3dafbe commit 5c55541

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,23 +238,20 @@ export abstract class ContextKeyExpr {
238238
private static _deserializeRegexValue(serializedValue: string): RegExp | null {
239239

240240
if (isFalsyOrWhitespace(serializedValue)) {
241-
console.warn('missing regexp-value for =~-expression');
242241
return null;
243242
}
244243

245244
const start = serializedValue.indexOf('/');
246245
const end = serializedValue.lastIndexOf('/');
247-
if (start === end || start < 0 /* || to < 0 */) {
248-
console.warn(`bad regexp-value '${serializedValue}', missing /-enclosure`);
246+
if (start === end || start < 0) {
249247
return null;
250248
}
251249

252250
const value = serializedValue.slice(start + 1, end);
253251
const caseIgnoreFlag = serializedValue[end + 1] === 'i' ? 'i' : '';
254252
try {
255253
return new RegExp(value, caseIgnoreFlag);
256-
} catch (e) {
257-
console.warn(`bad regexp-value '${serializedValue}', parse error: ${e}`);
254+
} catch (_e) {
258255
return null;
259256
}
260257
}
@@ -499,25 +496,23 @@ export class Parser {
499496

500497
let regex: RegExp | null = null;
501498

502-
if (isFalsyOrWhitespace(serializedValue)) {
503-
console.warn('missing regexp-value for =~-expression');
504-
} else {
499+
if (!isFalsyOrWhitespace(serializedValue)) {
505500
const start = serializedValue.indexOf('/');
506501
const end = serializedValue.lastIndexOf('/');
507-
if (start === end || start < 0 /* || to < 0 */) {
508-
console.warn(`bad regexp-value '${serializedValue}', missing /-enclosure`);
509-
} else {
502+
if (start !== end && start >= 0) {
510503

511504
const value = serializedValue.slice(start + 1, end);
512505
const caseIgnoreFlag = serializedValue[end + 1] === 'i' ? 'i' : '';
513506
try {
514507
regex = new RegExp(value, caseIgnoreFlag);
515-
} catch (e) {
516-
console.warn(`bad regexp-value '${serializedValue}', parse error: ${e}`);
517-
}
508+
} catch (_e) { }
518509
}
519510
}
520511

512+
if (regex === null) {
513+
throw this._errExpectedButGot('REGEX', expr);
514+
}
515+
521516
return ContextKeyRegexExpr.create(key, regex);
522517
}
523518

0 commit comments

Comments
 (0)