diff --git a/src/vs/base/browser/ui/checkbox/checkbox.ts b/src/vs/base/browser/ui/checkbox/checkbox.ts index ec8942b2f58..6b2ab1a64f6 100644 --- a/src/vs/base/browser/ui/checkbox/checkbox.ts +++ b/src/vs/base/browser/ui/checkbox/checkbox.ts @@ -17,7 +17,7 @@ export interface ICheckboxOpts { actionClassName: string; title: string; isChecked: boolean; - onChange: () => void; + onChange: (viaKeyboard: boolean) => void; onKeyDown?: (e: StandardKeyboardEvent) => void; } @@ -43,14 +43,14 @@ export class Checkbox extends Widget { this.onclick(this.domNode, (ev) => { this.checked = !this._checked; - this._opts.onChange(); + this._opts.onChange(false); ev.preventDefault(); }); this.onkeydown(this.domNode, (keyboardEvent) => { if (keyboardEvent.keyCode === KeyCode.Space || keyboardEvent.keyCode === KeyCode.Enter) { this.checked = !this._checked; - this._opts.onChange(); + this._opts.onChange(true); keyboardEvent.preventDefault(); return; } diff --git a/src/vs/base/browser/ui/findinput/findInput.ts b/src/vs/base/browser/ui/findinput/findInput.ts index 1b149b76490..e204dc1825a 100644 --- a/src/vs/base/browser/ui/findinput/findInput.ts +++ b/src/vs/base/browser/ui/findinput/findInput.ts @@ -58,8 +58,8 @@ export class FindInput extends Widget { public domNode: HTMLElement; public inputBox:InputBox; - private _onDidOptionChange = this._register(new Emitter()); - public onDidOptionChange: Event = this._onDidOptionChange.event; + private _onDidOptionChange = this._register(new Emitter()); + public onDidOptionChange: Event = this._onDidOptionChange.event; private _onKeyDown = this._register(new Emitter()); public onKeyDown: Event = this._onKeyDown.event; @@ -212,9 +212,11 @@ export class FindInput extends Widget { actionClassName: 'regex', title: NLS_REGEX_CHECKBOX_LABEL + appendRegexLabel, isChecked: false, - onChange: () => { - this._onDidOptionChange.fire(); - this.inputBox.focus(); + onChange: (viaKeyboard) => { + this._onDidOptionChange.fire(viaKeyboard); + if (!viaKeyboard) { + this.inputBox.focus(); + } this.setInputWidth(); this.validate(); } @@ -223,9 +225,11 @@ export class FindInput extends Widget { actionClassName: 'whole-word', title: NLS_WHOLE_WORD_CHECKBOX_LABEL + appendWholeWordsLabel, isChecked: false, - onChange: () => { - this._onDidOptionChange.fire(); - this.inputBox.focus(); + onChange: (viaKeyboard) => { + this._onDidOptionChange.fire(viaKeyboard); + if (!viaKeyboard) { + this.inputBox.focus(); + } this.setInputWidth(); this.validate(); } @@ -234,9 +238,11 @@ export class FindInput extends Widget { actionClassName: 'case-sensitive', title: NLS_CASE_SENSITIVE_CHECKBOX_LABEL + appendCaseSensitiveLabel, isChecked: false, - onChange: () => { - this._onDidOptionChange.fire(); - this.inputBox.focus(); + onChange: (viaKeyboard) => { + this._onDidOptionChange.fire(viaKeyboard); + if (!viaKeyboard) { + this.inputBox.focus(); + } this.setInputWidth(); this.validate(); }, diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index ed1996bfb86..42a92ccb22c 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -573,9 +573,11 @@ class PatternInput { actionClassName: 'pattern', title: nls.localize('patternDescription', "Use Glob Patterns"), isChecked: false, - onChange: () => { + onChange: (viaKeyboard) => { this.onOptionChange(null); - this.inputBox.focus(); + if (!viaKeyboard) { + this.inputBox.focus(); + } this.setInputWidth(); if (this.isGlobPattern()) { @@ -772,8 +774,8 @@ export class SearchViewlet extends Viewlet { } } }); - this.findInput.onDidOptionChange(() => { - this.onQueryChanged(true); + this.findInput.onDidOptionChange((viaKeyboard) => { + this.onQueryChanged(true, viaKeyboard); }); this.findInput.setValue(contentPattern); this.findInput.setRegex(isRegex); @@ -1099,7 +1101,7 @@ export class SearchViewlet extends Viewlet { } } - public onQueryChanged(rerunQuery: boolean): void { + public onQueryChanged(rerunQuery: boolean, preserveFocus?: boolean): void { let isRegex = this.findInput.getRegex(), isWholeWords = this.findInput.getWholeWords(), @@ -1167,7 +1169,9 @@ export class SearchViewlet extends Viewlet { this.queryBuilder.text(content, options) .then(query => this.onQueryTriggered(query, patternExcludes, patternIncludes), errors.onUnexpectedError); - this.findInput.focus(); // focus back to input field + if (!preserveFocus) { + this.findInput.focus(); // focus back to input field + } } private onQueryTriggered(query: ISearchQuery, excludePattern: string, includePattern: string): void {