From 5b28b6bbd488c2029b22edf9587ff42c5dc649e1 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Fri, 8 Jun 2018 17:52:04 +0200 Subject: [PATCH] #12645 Bring back focus next/previous input actions --- .../parts/search/browser/searchActions.ts | 36 +++++++++++++++++++ .../electron-browser/search.contribution.ts | 22 +++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/search/browser/searchActions.ts b/src/vs/workbench/parts/search/browser/searchActions.ts index 8ff668392e3..f891b325e60 100644 --- a/src/vs/workbench/parts/search/browser/searchActions.ts +++ b/src/vs/workbench/parts/search/browser/searchActions.ts @@ -92,6 +92,42 @@ export const FocusActiveEditorCommand = (accessor: ServicesAccessor) => { return TPromise.as(true); }; +export class FocusNextInputAction extends Action { + + public static readonly ID = 'search.focus.nextInputBox'; + + constructor(id: string, label: string, + @IViewletService private viewletService: IViewletService, + @IPanelService private panelService: IPanelService + ) { + super(id, label); + } + + public run(): TPromise { + const searchView = getSearchView(this.viewletService, this.panelService); + searchView.focusNextInputBox(); + return TPromise.as(null); + } +} + +export class FocusPreviousInputAction extends Action { + + public static readonly ID = 'search.focus.previousInputBox'; + + constructor(id: string, label: string, + @IViewletService private viewletService: IViewletService, + @IPanelService private panelService: IPanelService + ) { + super(id, label); + } + + public run(): TPromise { + const searchView = getSearchView(this.viewletService, this.panelService); + searchView.focusPreviousInputBox(); + return TPromise.as(null); + } +} + export abstract class FindOrReplaceInFilesAction extends Action { constructor(id: string, label: string, private viewletService: IViewletService, private panelService: IPanelService, 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 348b7a8b542..8c98e2a8ce6 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, FocusActiveEditorCommand, toggleCaseSensitiveCommand, toggleRegexCommand, CollapseDeepestExpandedLevelAction, toggleWholeWordCommand, RemoveAction, ReplaceAction, ClearSearchResultsAction, copyPathCommand, copyMatchCommand, copyAllCommand, clearHistoryCommand } from 'vs/workbench/parts/search/browser/searchActions'; +import { openSearchView, getSearchView, ReplaceAllInFolderAction, ReplaceAllAction, CloseReplaceAction, FocusNextSearchResultAction, FocusPreviousSearchResultAction, ReplaceInFilesAction, FindInFilesAction, FocusActiveEditorCommand, toggleCaseSensitiveCommand, toggleRegexCommand, CollapseDeepestExpandedLevelAction, toggleWholeWordCommand, RemoveAction, ReplaceAction, ClearSearchResultsAction, copyPathCommand, copyMatchCommand, copyAllCommand, clearHistoryCommand, FocusNextInputAction, FocusPreviousInputAction } 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'; @@ -179,6 +179,26 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ } }); +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: FocusNextInputAction.ID, + weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.InputBoxFocusedKey), + primary: null, + handler: (accessor, args: any) => { + accessor.get(IInstantiationService).createInstance(FocusNextInputAction, FocusNextInputAction.ID, '').run(); + } +}); + +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: FocusPreviousInputAction.ID, + weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.InputBoxFocusedKey, Constants.SearchInputBoxFocusedKey.toNegated()), + primary: null, + handler: (accessor, args: any) => { + accessor.get(IInstantiationService).createInstance(FocusPreviousInputAction, FocusPreviousInputAction.ID, '').run(); + } +}); + MenuRegistry.appendMenuItem(MenuId.SearchContext, { command: { id: Constants.ReplaceActionId, -- GitLab