提交 e4a77a80 编写于 作者: J Jackson Kearl

Fix #100328: search view: preserve last focused item

上级 ff5a252d
......@@ -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;
......@@ -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
......@@ -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);
......@@ -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';
}
}));
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册