Skip to content

Commit

Permalink
Merge pull request #54196 from yogeshmangaj/focus-search-list-command
Browse files Browse the repository at this point in the history
Add Focus search list command. Fixes #53696
  • Loading branch information
roblourens authored Jul 13, 2018
2 parents a874e01 + f9e0f8d commit e89ed6e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/vs/workbench/parts/search/browser/searchActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
};
4 changes: 4 additions & 0 deletions src/vs/workbench/parts/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/parts/search/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e89ed6e

Please sign in to comment.