diff --git a/src/vs/workbench/parts/search/browser/searchActions.ts b/src/vs/workbench/parts/search/browser/searchActions.ts index 50925449d9a6eb8e021862c7cc89b1395caea374..f9483bb4466f436c642a5a30add5f9b9ae2c9516 100644 --- a/src/vs/workbench/parts/search/browser/searchActions.ts +++ b/src/vs/workbench/parts/search/browser/searchActions.ts @@ -671,3 +671,11 @@ export const clearHistoryCommand: ICommandHandler = accessor => { const searchHistoryService = accessor.get(ISearchHistoryService); searchHistoryService.clearHistory(); }; + +export const focusSearchListCommand: ICommandHandler = accessor => { + const viewletService = accessor.get(IViewletService); + const panelService = accessor.get(IPanelService); + openSearchView(viewletService, panelService).then(searchView => { + searchView.moveFocusToResults(); + }); +}; diff --git a/src/vs/workbench/parts/search/browser/searchView.ts b/src/vs/workbench/parts/search/browser/searchView.ts index c1af207900027a2286b90b53c4174724c6618fe6..fb02650821ef314909e6f62e80176b24d382c75d 100644 --- a/src/vs/workbench/parts/search/browser/searchView.ts +++ b/src/vs/workbench/parts/search/browser/searchView.ts @@ -732,6 +732,10 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { return promise; } + public moveFocusToResults(): void { + this.tree.domFocus(); + } + public focus(): void { super.focus(); diff --git a/src/vs/workbench/parts/search/common/constants.ts b/src/vs/workbench/parts/search/common/constants.ts index 39abb302748c2f57d3783563a81db848f568da02..1f15c344c0e7d8379263e0df3a2d375d274051dc 100644 --- a/src/vs/workbench/parts/search/common/constants.ts +++ b/src/vs/workbench/parts/search/common/constants.ts @@ -16,6 +16,7 @@ export const CopyPathCommandId = 'search.action.copyPath'; export const CopyMatchCommandId = 'search.action.copyMatch'; export const CopyAllCommandId = 'search.action.copyAll'; export const ClearSearchHistoryCommandId = 'search.action.clearHistory'; +export const FocusSearchListCommandID = 'search.action.focusSearchList'; export const ReplaceActionId = 'search.action.replace'; export const ReplaceAllInFileActionId = 'search.action.replaceAllInFile'; export const ReplaceAllInFolderActionId = 'search.action.replaceAllInFolder'; diff --git a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts index bff2ceb88c9236003434ae81bd4af15ba6672282..6aabebef7d994734372d8cf15596a4e888ec1eed 100644 --- a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts @@ -52,7 +52,7 @@ import { getMultiSelectedResources } from 'vs/workbench/parts/files/browser/file import { Schemas } from 'vs/base/common/network'; import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; -import { openSearchView, getSearchView, ReplaceAllInFolderAction, ReplaceAllAction, CloseReplaceAction, FocusNextSearchResultAction, FocusPreviousSearchResultAction, ReplaceInFilesAction, FindInFilesAction, toggleCaseSensitiveCommand, toggleRegexCommand, CollapseDeepestExpandedLevelAction, toggleWholeWordCommand, RemoveAction, ReplaceAction, ClearSearchResultsAction, copyPathCommand, copyMatchCommand, copyAllCommand, clearHistoryCommand, FocusNextInputAction, FocusPreviousInputAction, RefreshAction } from 'vs/workbench/parts/search/browser/searchActions'; +import { openSearchView, getSearchView, ReplaceAllInFolderAction, ReplaceAllAction, CloseReplaceAction, FocusNextSearchResultAction, FocusPreviousSearchResultAction, ReplaceInFilesAction, FindInFilesAction, toggleCaseSensitiveCommand, toggleRegexCommand, CollapseDeepestExpandedLevelAction, toggleWholeWordCommand, RemoveAction, ReplaceAction, ClearSearchResultsAction, copyPathCommand, copyMatchCommand, copyAllCommand, clearHistoryCommand, FocusNextInputAction, FocusPreviousInputAction, RefreshAction, focusSearchListCommand } from 'vs/workbench/parts/search/browser/searchActions'; import { VIEW_ID, ISearchConfigurationProperties } from 'vs/platform/search/common/search'; import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; @@ -331,6 +331,19 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, { order: 1 }); +CommandsRegistry.registerCommand({ + id: Constants.FocusSearchListCommandID, + handler: focusSearchListCommand +}); + +const focusSearchListCommandLabel = nls.localize('focusSearchListCommandLabel', "Focus List"); +const FocusSearchListCommand: ICommandAction = { + id: Constants.FocusSearchListCommandID, + title: focusSearchListCommandLabel, + category +}; +MenuRegistry.addCommand(FocusSearchListCommand); + const FIND_IN_FOLDER_ID = 'filesExplorer.findInFolder'; CommandsRegistry.registerCommand({ id: FIND_IN_FOLDER_ID,