Skip to content

Commit b71932d

Browse files
authored
Merge pull request microsoft#70167 from irrationalRock/fix-59368
Fixed microsoft#59368
2 parents ff12b2a + 6dc70b0 commit b71932d

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/vs/editor/contrib/find/findWidget.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,16 +764,12 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
764764
appendWholeWordsLabel: this._keybindingLabelFor(FIND_IDS.ToggleWholeWordCommand),
765765
appendRegexLabel: this._keybindingLabelFor(FIND_IDS.ToggleRegexCommand),
766766
validation: (value: string): InputBoxMessage | null => {
767-
if (value.length === 0) {
768-
return null;
769-
}
770-
if (!this._findInput.getRegex()) {
767+
if (value.length === 0 || !this._findInput.getRegex()) {
771768
return null;
772769
}
773770
try {
774-
/* tslint:disable:no-unused-expression */
771+
/* tslint:disable-next-line:no-unused-expression */
775772
new RegExp(value);
776-
/* tslint:enable:no-unused-expression */
777773
return null;
778774
} catch (e) {
779775
return { content: e.message };

src/vs/editor/contrib/find/simpleFindWidget.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Widget } from 'vs/base/browser/ui/widget';
1111
import { Delayer } from 'vs/base/common/async';
1212
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
1313
import { FindReplaceState } from 'vs/editor/contrib/find/findState';
14+
import { IMessage as InputBoxMessage } from 'vs/base/browser/ui/inputbox/inputBox';
1415
import { SimpleButton } from 'vs/editor/contrib/find/findWidget';
1516
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1617
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
@@ -44,6 +45,18 @@ export abstract class SimpleFindWidget extends Widget {
4445
this._findInput = this._register(new ContextScopedFindInput(null, this._contextViewService, {
4546
label: NLS_FIND_INPUT_LABEL,
4647
placeholder: NLS_FIND_INPUT_PLACEHOLDER,
48+
validation: (value: string): InputBoxMessage | null => {
49+
if (value.length === 0 || !this._findInput.getRegex()) {
50+
return null;
51+
}
52+
try {
53+
/* tslint:disable-next-line:no-unused-expression */
54+
new RegExp(value);
55+
return null;
56+
} catch (e) {
57+
return { content: e.message };
58+
}
59+
}
4760
}, contextKeyService, showOptionButtons));
4861

4962
// Find History with update delayer

0 commit comments

Comments
 (0)