Skip to content

Commit

Permalink
Merge branch 'master' into bamurtaugh/install-debug-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
bamurtaugh authored Aug 12, 2020
2 parents a6e9a6a + e4a77a8 commit cfa0e31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.49.0",
"distro": "d368861bfb088f58e20fd0ebbcaeac0104e81f80",
"distro": "af085a7e151908a14d22a08a22374f924b8a593d",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
14 changes: 12 additions & 2 deletions src/vs/workbench/contrib/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class SearchView extends ViewPane {
private folderMatchFocused: IContextKey<boolean>;
private matchFocused: IContextKey<boolean>;
private hasSearchResultsKey: IContextKey<boolean>;
private lastFocusState: 'input' | 'tree' = 'input';

private state: SearchUIState = SearchUIState.Idle;

Expand Down Expand Up @@ -376,6 +377,9 @@ export class SearchView extends ViewPane {
this.updateActions();
this.updatedActionsWhileHidden = false;
}
} else {
// Reset last focus to input to preserve opening the viewlet always focusing the query editor.
this.lastFocusState = 'input';
}

// Enable highlights if there are searchresults
Expand Down Expand Up @@ -476,6 +480,7 @@ export class SearchView extends ViewPane {

private trackInputBox(inputFocusTracker: dom.IFocusTracker, contextKey?: IContextKey<boolean>): void {
this._register(inputFocusTracker.onDidFocus(() => {
this.lastFocusState = 'input';
this.inputBoxFocused.set(true);
if (contextKey) {
contextKey.set(true);
Expand Down Expand Up @@ -751,6 +756,7 @@ export class SearchView extends ViewPane {
this.matchFocused.set(focus instanceof Match);
this.fileMatchOrFolderMatchFocus.set(focus instanceof FileMatch || focus instanceof FolderMatch);
this.fileMatchOrFolderMatchWithResourceFocus.set(focus instanceof FileMatch || focus instanceof FolderMatchWithResource);
this.lastFocusState = 'tree';
}
}));

Expand Down Expand Up @@ -874,8 +880,12 @@ export class SearchView extends ViewPane {

focus(): void {
super.focus();
const updatedText = this.searchConfig.seedOnFocus ? this.updateTextFromSelection({ allowSearchOnType: false }) : false;
this.searchWidget.focus(undefined, undefined, updatedText);
if (this.lastFocusState === 'input' || !this.hasSearchResults()) {
const updatedText = this.searchConfig.seedOnFocus ? this.updateTextFromSelection({ allowSearchOnType: false }) : false;
this.searchWidget.focus(undefined, undefined, updatedText);
} else {
this.tree.domFocus();
}
}

updateTextFromSelection({ allowUnselectedWord = true, allowSearchOnType = true }): boolean {
Expand Down

0 comments on commit cfa0e31

Please sign in to comment.