Skip to content

Commit e89ed6e

Browse files
authored
Merge pull request microsoft#54196 from yogeshmangaj/focus-search-list-command
Add Focus search list command. Fixes microsoft#53696
2 parents a874e01 + f9e0f8d commit e89ed6e

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/vs/workbench/parts/search/browser/searchActions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,11 @@ export const clearHistoryCommand: ICommandHandler = accessor => {
671671
const searchHistoryService = accessor.get(ISearchHistoryService);
672672
searchHistoryService.clearHistory();
673673
};
674+
675+
export const focusSearchListCommand: ICommandHandler = accessor => {
676+
const viewletService = accessor.get(IViewletService);
677+
const panelService = accessor.get(IPanelService);
678+
openSearchView(viewletService, panelService).then(searchView => {
679+
searchView.moveFocusToResults();
680+
});
681+
};

src/vs/workbench/parts/search/browser/searchView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,10 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
732732
return promise;
733733
}
734734

735+
public moveFocusToResults(): void {
736+
this.tree.domFocus();
737+
}
738+
735739
public focus(): void {
736740
super.focus();
737741

src/vs/workbench/parts/search/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const CopyPathCommandId = 'search.action.copyPath';
1616
export const CopyMatchCommandId = 'search.action.copyMatch';
1717
export const CopyAllCommandId = 'search.action.copyAll';
1818
export const ClearSearchHistoryCommandId = 'search.action.clearHistory';
19+
export const FocusSearchListCommandID = 'search.action.focusSearchList';
1920
export const ReplaceActionId = 'search.action.replace';
2021
export const ReplaceAllInFileActionId = 'search.action.replaceAllInFile';
2122
export const ReplaceAllInFolderActionId = 'search.action.replaceAllInFolder';

src/vs/workbench/parts/search/electron-browser/search.contribution.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { getMultiSelectedResources } from 'vs/workbench/parts/files/browser/file
5252
import { Schemas } from 'vs/base/common/network';
5353
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
5454
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
55-
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';
55+
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';
5656
import { VIEW_ID, ISearchConfigurationProperties } from 'vs/platform/search/common/search';
5757
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
5858
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
@@ -331,6 +331,19 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, {
331331
order: 1
332332
});
333333

334+
CommandsRegistry.registerCommand({
335+
id: Constants.FocusSearchListCommandID,
336+
handler: focusSearchListCommand
337+
});
338+
339+
const focusSearchListCommandLabel = nls.localize('focusSearchListCommandLabel', "Focus List");
340+
const FocusSearchListCommand: ICommandAction = {
341+
id: Constants.FocusSearchListCommandID,
342+
title: focusSearchListCommandLabel,
343+
category
344+
};
345+
MenuRegistry.addCommand(FocusSearchListCommand);
346+
334347
const FIND_IN_FOLDER_ID = 'filesExplorer.findInFolder';
335348
CommandsRegistry.registerCommand({
336349
id: FIND_IN_FOLDER_ID,

0 commit comments

Comments
 (0)