提交 b3e6d5bb 编写于 作者: R Rob Lourens

Add 'folderMatchFocus' context key and keybinding for "replace all in folder" action - #31260

上级 6ceefbe5
......@@ -141,6 +141,18 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: Constants.ReplaceAllInFolderActionId,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.ReplaceActiveKey, Constants.FolderFocusKey),
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter,
handler: (accessor, args: any) => {
const searchViewlet: SearchViewlet = <SearchViewlet>accessor.get(IViewletService).getActiveViewlet();
const tree: ITree = searchViewlet.getControl();
accessor.get(IInstantiationService).createInstance(searchActions.ReplaceAllInFolderAction, tree, tree.getFocus()).run();
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: Constants.CloseReplaceWidgetActionId,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
......
......@@ -10,7 +10,6 @@ import resources = require('vs/base/common/resources');
import { TPromise } from 'vs/base/common/winjs.base';
import URI from 'vs/base/common/uri';
import { Action } from 'vs/base/common/actions';
import { ToggleViewletAction } from 'vs/workbench/browser/viewlet';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { INavigator } from 'vs/base/common/iterator';
......@@ -586,7 +585,7 @@ export class ReplaceAllInFolderAction extends AbstractSearchAndReplaceAction {
@IKeybindingService keyBindingService: IKeybindingService,
@ITelemetryService private telemetryService: ITelemetryService
) {
super(Constants.ReplaceAllInFileActionId, nls.localize('file.replaceAll.label', "Replace All"), 'action-replace-all');
super(Constants.ReplaceAllInFolderActionId, nls.localize('file.replaceAll.label', "Replace All"), 'action-replace-all');
}
public async run(): TPromise<any> {
......
......@@ -28,7 +28,7 @@ import { IPreferencesService } from 'vs/workbench/parts/preferences/common/prefe
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { FileChangeType, FileChangesEvent, IFileService } from 'vs/platform/files/common/files';
import { Viewlet } from 'vs/workbench/browser/viewlet';
import { Match, FileMatch, SearchModel, FileMatchOrMatch, IChangeEvent, ISearchWorkbenchService } from 'vs/workbench/parts/search/common/searchModel';
import { Match, FileMatch, SearchModel, FileMatchOrMatch, IChangeEvent, ISearchWorkbenchService, FolderMatch } from 'vs/workbench/parts/search/common/searchModel';
import { QueryBuilder } from 'vs/workbench/parts/search/common/queryBuilder';
import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import { ISearchProgressItem, ISearchComplete, ISearchQuery, IQueryOptions, ISearchConfiguration } from 'vs/platform/search/common/search';
......@@ -80,6 +80,7 @@ export class SearchViewlet extends Viewlet {
private firstMatchFocused: IContextKey<boolean>;
private fileMatchOrMatchFocused: IContextKey<boolean>;
private fileMatchFocused: IContextKey<boolean>;
private folderMatchFocused: IContextKey<boolean>;
private matchFocused: IContextKey<boolean>;
private actionRegistry: { [key: string]: Action; };
......@@ -132,6 +133,7 @@ export class SearchViewlet extends Viewlet {
this.firstMatchFocused = Constants.FirstMatchFocusKey.bindTo(contextKeyService);
this.fileMatchOrMatchFocused = Constants.FileMatchOrMatchFocusKey.bindTo(contextKeyService);
this.fileMatchFocused = Constants.FileFocusKey.bindTo(contextKeyService);
this.folderMatchFocused = Constants.FolderFocusKey.bindTo(contextKeyService);
this.matchFocused = Constants.MatchFocusKey.bindTo(this.contextKeyService);
this.queryBuilder = this.instantiationService.createInstance(QueryBuilder);
......@@ -527,6 +529,7 @@ export class SearchViewlet extends Viewlet {
this.firstMatchFocused.set(this.tree.getNavigator().first() === focus);
this.fileMatchOrMatchFocused.set(true);
this.fileMatchFocused.set(focus instanceof FileMatch);
this.folderMatchFocused.set(focus instanceof FolderMatch);
this.matchFocused.set(focus instanceof Match);
}));
......@@ -534,6 +537,7 @@ export class SearchViewlet extends Viewlet {
this.firstMatchFocused.reset();
this.fileMatchOrMatchFocused.reset();
this.fileMatchFocused.reset();
this.folderMatchFocused.reset();
this.matchFocused.reset();
}));
......
......@@ -16,6 +16,7 @@ export const CancelActionId = 'search.action.cancel';
export const RemoveActionId = 'search.action.remove';
export const ReplaceActionId = 'search.action.replace';
export const ReplaceAllInFileActionId = 'search.action.replaceAllInFile';
export const ReplaceAllInFolderActionId = 'search.action.replaceAllInFolder';
export const CloseReplaceWidgetActionId = 'closeReplaceInFilesWidget';
export const ToggleCaseSensitiveCommandId = 'toggleSearchCaseSensitive';
export const ToggleWholeWordCommandId = 'toggleSearchWholeWord';
......@@ -32,4 +33,5 @@ export const ReplaceActiveKey = new RawContextKey<boolean>('replaceActive', fals
export const FirstMatchFocusKey = new RawContextKey<boolean>('firstMatchFocus', false);
export const FileMatchOrMatchFocusKey = new RawContextKey<boolean>('fileMatchOrMatchFocus', false);
export const FileFocusKey = new RawContextKey<boolean>('fileMatchFocus', false);
export const FolderFocusKey = new RawContextKey<boolean>('folderMatchFocus', false);
export const MatchFocusKey = new RawContextKey<boolean>('matchFocus', false);
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册