diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 506c3f9ec4da..0e0a0adb48c6 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -245,7 +245,7 @@ export class SearchView extends ViewletPanel { if (this.searchWidget.isReplaceActive()) { this.searchWidget.focusReplaceAllAction(); } else { - this.searchWidget.focusRegexAction(); + this.searchWidget.isReplaceShown() ? this.searchWidget.replaceInput.focusOnPreserve() : this.searchWidget.focusRegexAction(); } dom.EventHelper.stop(e); } diff --git a/src/vs/workbench/contrib/search/browser/searchWidget.ts b/src/vs/workbench/contrib/search/browser/searchWidget.ts index 96631434ff14..263b79b88f72 100644 --- a/src/vs/workbench/contrib/search/browser/searchWidget.ts +++ b/src/vs/workbench/contrib/search/browser/searchWidget.ts @@ -389,6 +389,7 @@ export class SearchWidget extends Widget { this.replaceInputFocusTracker = this._register(dom.trackFocus(this.replaceInput.inputBox.inputElement)); this._register(this.replaceInputFocusTracker.onDidFocus(() => this.replaceInputBoxFocused.set(true))); this._register(this.replaceInputFocusTracker.onDidBlur(() => this.replaceInputBoxFocused.set(false))); + this._register(this.replaceInput.onPreserveCaseKeyDown((keyboardEvent: IKeyboardEvent) => this.onPreserveCaseKeyDown(keyboardEvent))); } triggerReplaceAll(): Promise { @@ -495,6 +496,15 @@ export class SearchWidget extends Widget { } private onRegexKeyDown(keyboardEvent: IKeyboardEvent) { + if (keyboardEvent.equals(KeyCode.Tab)) { + if (this.isReplaceShown()) { + this.replaceInput.focusOnPreserve(); + keyboardEvent.preventDefault(); + } + } + } + + private onPreserveCaseKeyDown(keyboardEvent: IKeyboardEvent) { if (keyboardEvent.equals(KeyCode.Tab)) { if (this.isReplaceActive()) { this.focusReplaceAllAction(); @@ -503,6 +513,10 @@ export class SearchWidget extends Widget { } keyboardEvent.preventDefault(); } + else if (KeyMod.Shift | KeyCode.Tab) { + this.focusRegexAction(); + keyboardEvent.preventDefault(); + } } private onReplaceInputKeyDown(keyboardEvent: IKeyboardEvent) {