Skip to content

Commit d11149a

Browse files
authored
Merge pull request microsoft#250132 from microsoft/osortega/find-option-as-you-type
Find as you type setting
2 parents d4baa54 + 85eb5fb commit d11149a

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/vs/editor/common/config/editorOptions.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,10 @@ export interface IEditorFindOptions {
16561656
* Controls whether the cursor should move to find matches while typing.
16571657
*/
16581658
cursorMoveOnType?: boolean;
1659+
/**
1660+
* Controls whether the find widget should search as you type.
1661+
*/
1662+
findOnType?: boolean;
16591663
/**
16601664
* Controls if we seed search string in the Find Widget with editor selection.
16611665
*/
@@ -1699,6 +1703,7 @@ class EditorFind extends BaseEditorOption<EditorOption.find, IEditorFindOptions,
16991703
constructor() {
17001704
const defaults: EditorFindOptions = {
17011705
cursorMoveOnType: true,
1706+
findOnType: true,
17021707
seedSearchStringFromSelection: 'always',
17031708
autoFindInSelection: 'never',
17041709
globalFindClipboard: false,
@@ -1772,7 +1777,12 @@ class EditorFind extends BaseEditorOption<EditorOption.find, IEditorFindOptions,
17721777
nls.localize('editor.find.replaceHistory.workspace', 'Store replace history across the active workspace'),
17731778
],
17741779
description: nls.localize('find.replaceHistory', "Controls how the replace widget history should be stored")
1775-
}
1780+
},
1781+
'editor.find.findOnType': {
1782+
type: 'boolean',
1783+
default: defaults.findOnType,
1784+
description: nls.localize('find.findOnType', "Controls whether the Find Widget should search as you type.")
1785+
},
17761786
}
17771787
);
17781788
}
@@ -1784,6 +1794,7 @@ class EditorFind extends BaseEditorOption<EditorOption.find, IEditorFindOptions,
17841794
const input = _input as IEditorFindOptions;
17851795
return {
17861796
cursorMoveOnType: boolean(input.cursorMoveOnType, this.defaultValue.cursorMoveOnType),
1797+
findOnType: boolean(input.findOnType, this.defaultValue.findOnType),
17871798
seedSearchStringFromSelection: typeof _input.seedSearchStringFromSelection === 'boolean'
17881799
? (_input.seedSearchStringFromSelection ? 'always' : 'never')
17891800
: stringSet<'never' | 'always' | 'selection'>(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection, ['never', 'always', 'selection']),

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,9 +951,14 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
951951
this._findInput.setRegex(!!this._state.isRegex);
952952
this._findInput.setCaseSensitive(!!this._state.matchCase);
953953
this._findInput.setWholeWords(!!this._state.wholeWord);
954-
this._register(this._findInput.onKeyDown((e) => this._onFindInputKeyDown(e)));
954+
this._register(this._findInput.onKeyDown((e) => {
955+
if (e.equals(KeyCode.Enter) && !this._codeEditor.getOption(EditorOption.find).findOnType) {
956+
this._state.change({ searchString: this._findInput.getValue() }, true);
957+
}
958+
this._onFindInputKeyDown(e);
959+
}));
955960
this._register(this._findInput.inputBox.onDidChange(() => {
956-
if (this._ignoreChangeEvent) {
961+
if (this._ignoreChangeEvent || !this._codeEditor.getOption(EditorOption.find).findOnType) {
957962
return;
958963
}
959964
this._state.change({ searchString: this._findInput.getValue() }, true);

src/vs/monaco.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,6 +4076,10 @@ declare namespace monaco.editor {
40764076
* Controls whether the cursor should move to find matches while typing.
40774077
*/
40784078
cursorMoveOnType?: boolean;
4079+
/**
4080+
* Controls whether the find widget should search as you type.
4081+
*/
4082+
findOnType?: boolean;
40794083
/**
40804084
* Controls if we seed search string in the Find Widget with editor selection.
40814085
*/

0 commit comments

Comments
 (0)