Skip to content

Commit

Permalink
microsoft#12645 Bring back focus next/previous input actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jun 8, 2018
1 parent 19dcc2d commit 5b28b6b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/vs/workbench/parts/search/browser/searchActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
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<any> {
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,
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, 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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5b28b6b

Please sign in to comment.