Skip to content

Commit f9a21ff

Browse files
committed
Find as you type setting
1 parent d4c6686 commit f9a21ff

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
@@ -1649,6 +1649,10 @@ export interface IEditorFindOptions {
16491649
* Controls whether the cursor should move to find matches while typing.
16501650
*/
16511651
cursorMoveOnType?: boolean;
1652+
/**
1653+
* Controls whether the find widget should search as you type.
1654+
*/
1655+
findOnType?: boolean;
16521656
/**
16531657
* Controls if we seed search string in the Find Widget with editor selection.
16541658
*/
@@ -1692,6 +1696,7 @@ class EditorFind extends BaseEditorOption<EditorOption.find, IEditorFindOptions,
16921696
constructor() {
16931697
const defaults: EditorFindOptions = {
16941698
cursorMoveOnType: true,
1699+
findOnType: true,
16951700
seedSearchStringFromSelection: 'always',
16961701
autoFindInSelection: 'never',
16971702
globalFindClipboard: false,
@@ -1765,7 +1770,12 @@ class EditorFind extends BaseEditorOption<EditorOption.find, IEditorFindOptions,
17651770
nls.localize('editor.find.replaceHistory.workspace', 'Store replace history across the active workspace'),
17661771
],
17671772
description: nls.localize('find.replaceHistory', "Controls how the replace widget history should be stored")
1768-
}
1773+
},
1774+
'editor.find.findOnType': {
1775+
type: 'boolean',
1776+
default: defaults.findOnType,
1777+
description: nls.localize('find.findOnType', "Controls whether the Find Widget should search as you type.")
1778+
},
17691779
}
17701780
);
17711781
}
@@ -1777,6 +1787,7 @@ class EditorFind extends BaseEditorOption<EditorOption.find, IEditorFindOptions,
17771787
const input = _input as IEditorFindOptions;
17781788
return {
17791789
cursorMoveOnType: boolean(input.cursorMoveOnType, this.defaultValue.cursorMoveOnType),
1790+
findOnType: boolean(input.findOnType, this.defaultValue.findOnType),
17801791
seedSearchStringFromSelection: typeof _input.seedSearchStringFromSelection === 'boolean'
17811792
? (_input.seedSearchStringFromSelection ? 'always' : 'never')
17821793
: 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)) {
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)