search.contribution.ts 22.8 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import 'vs/css!./media/search.contribution';
9
import { Registry } from 'vs/platform/registry/common/platform';
S
Sandeep Somavarapu 已提交
10
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
J
Johannes Rieken 已提交
11
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
S
Sandeep Somavarapu 已提交
12
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
E
Erich Gamma 已提交
13
import nls = require('vs/nls');
14 15
import { TPromise } from 'vs/base/common/winjs.base';
import { IAction, Action } from 'vs/base/common/actions';
R
Rob Lourens 已提交
16
import * as objects from 'vs/base/common/objects';
17
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
18
import { explorerItemToFileResource } from 'vs/workbench/parts/files/common/files';
B
Benjamin Pasero 已提交
19
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
J
Johannes Rieken 已提交
20
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
21
import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor } from 'vs/workbench/browser/actions';
B
Benjamin Pasero 已提交
22
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
O
Oleg Mihailik 已提交
23
import { QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions as QuickOpenExtensions } from 'vs/workbench/browser/quickopen';
J
Johannes Rieken 已提交
24 25 26
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
J
Johannes Rieken 已提交
27
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
28
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
29
import { getSelectionSearchString } from 'vs/editor/contrib/find/findController';
B
Benjamin Pasero 已提交
30
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
J
Johannes Rieken 已提交
31
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
S
Sandeep Somavarapu 已提交
32
import { ITree } from 'vs/base/parts/tree/browser/tree';
S
Sandeep Somavarapu 已提交
33
import * as searchActions from 'vs/workbench/parts/search/browser/searchActions';
34
import { Model } from 'vs/workbench/parts/files/common/explorerModel';
35
import * as Constants from 'vs/workbench/parts/search/common/constants';
36 37
import { registerContributions as replaceContributions } from 'vs/workbench/parts/search/browser/replaceContributions';
import { registerContributions as searchWidgetContributions } from 'vs/workbench/parts/search/browser/searchWidget';
38
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
39
import { ToggleCaseSensitiveKeybinding, ToggleRegexKeybinding, ToggleWholeWordKeybinding, ShowPreviousFindTermKeybinding, ShowNextFindTermKeybinding } from 'vs/editor/contrib/find/findModel';
S
Sandeep Somavarapu 已提交
40
import { ISearchWorkbenchService, SearchWorkbenchService } from 'vs/workbench/parts/search/common/searchModel';
41
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
42
import { SearchViewlet } from 'vs/workbench/parts/search/browser/searchViewlet';
43
import { IOutputChannelRegistry, Extensions as OutputExt } from 'vs/workbench/parts/output/common/output';
B
Benjamin Pasero 已提交
44
import { defaultQuickOpenContextKey } from 'vs/workbench/browser/parts/quickopen/quickopen';
45 46
import { OpenSymbolHandler } from 'vs/workbench/parts/search/browser/openSymbolHandler';
import { OpenAnythingHandler } from 'vs/workbench/parts/search/browser/openAnythingHandler';
47
import { registerLanguageCommand } from 'vs/editor/browser/editorExtensions';
48 49
import { getWorkspaceSymbols } from 'vs/workbench/parts/search/common/search';
import { illegalArgument } from 'vs/base/common/errors';
50
import { FindInFolderAction, findInFolderCommand, FindInWorkspaceAction } from 'vs/workbench/parts/search/electron-browser/searchActions';
J
Joao Moreno 已提交
51
import { WorkbenchListFocusContextKey } from 'vs/platform/list/browser/listService';
52

S
Sandeep Somavarapu 已提交
53
registerSingleton(ISearchWorkbenchService, SearchWorkbenchService);
54 55
replaceContributions();
searchWidgetContributions();
E
Erich Gamma 已提交
56

A
Alex Dima 已提交
57
KeybindingsRegistry.registerCommandAndKeybindingRule({
E
Erich Gamma 已提交
58 59
	id: 'workbench.action.search.toggleQueryDetails',
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
60
	when: Constants.SearchViewletVisibleKey,
E
Erich Gamma 已提交
61
	primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_J,
62 63
	handler: accessor => {
		let viewletService = accessor.get(IViewletService);
64
		viewletService.openViewlet(Constants.VIEWLET_ID, true)
65
			.then((viewlet: SearchViewlet) => viewlet.toggleQueryDetails());
E
Erich Gamma 已提交
66 67 68
	}
});

S
Sandeep Somavarapu 已提交
69 70 71 72 73 74 75
KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.FocusSearchFromResults,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.FirstMatchFocusKey),
	primary: KeyCode.UpArrow,
	handler: (accessor, args: any) => {
		const searchViewlet: SearchViewlet = <SearchViewlet>accessor.get(IViewletService).getActiveViewlet();
S
Sandeep Somavarapu 已提交
76
		searchViewlet.focusPreviousInputBox();
S
Sandeep Somavarapu 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.OpenMatchToSide,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.FileMatchOrMatchFocusKey),
	primary: KeyMod.CtrlCmd | KeyCode.Enter,
	mac: {
		primary: KeyMod.WinCtrl | KeyCode.Enter
	},
	handler: (accessor, args: any) => {
		const searchViewlet: SearchViewlet = <SearchViewlet>accessor.get(IViewletService).getActiveViewlet();
		const tree: ITree = searchViewlet.getControl();
		searchViewlet.open(tree.getFocus(), false, true, true);
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.CancelActionId,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
J
Joao Moreno 已提交
98
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, WorkbenchListFocusContextKey),
S
Sandeep Somavarapu 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
	primary: KeyCode.Escape,
	handler: (accessor, args: any) => {
		const searchViewlet: SearchViewlet = <SearchViewlet>accessor.get(IViewletService).getActiveViewlet();
		searchViewlet.cancelSearch();
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.RemoveActionId,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.FileMatchOrMatchFocusKey),
	primary: KeyCode.Delete,
	mac: {
		primary: KeyMod.CtrlCmd | KeyCode.Backspace,
	},
	handler: (accessor, args: any) => {
		const searchViewlet: SearchViewlet = <SearchViewlet>accessor.get(IViewletService).getActiveViewlet();
		const tree: ITree = searchViewlet.getControl();
		accessor.get(IInstantiationService).createInstance(searchActions.RemoveAction, tree, tree.getFocus(), searchViewlet).run();
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.ReplaceActionId,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.ReplaceActiveKey, Constants.MatchFocusKey),
	primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.KEY_1,
	handler: (accessor, args: any) => {
		const searchViewlet: SearchViewlet = <SearchViewlet>accessor.get(IViewletService).getActiveViewlet();
		const tree: ITree = searchViewlet.getControl();
		accessor.get(IInstantiationService).createInstance(searchActions.ReplaceAction, tree, tree.getFocus(), searchViewlet).run();
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.ReplaceAllInFileActionId,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.ReplaceActiveKey, Constants.FileFocusKey),
	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.ReplaceAllAction, tree, tree.getFocus(), searchViewlet).run();
	}
});

145 146 147 148 149 150 151 152 153 154 155 156
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();
	}
});

S
Sandeep Somavarapu 已提交
157 158 159
KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.CloseReplaceWidgetActionId,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
160
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.ReplaceInputBoxFocusedKey),
S
Sandeep Somavarapu 已提交
161 162 163 164 165 166 167 168 169
	primary: KeyCode.Escape,
	handler: (accessor, args: any) => {
		accessor.get(IInstantiationService).createInstance(searchActions.CloseReplaceAction, Constants.CloseReplaceWidgetActionId, '').run();
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: searchActions.FocusNextInputAction.ID,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
170
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.InputBoxFocusedKey),
S
Sandeep Somavarapu 已提交
171 172 173 174 175 176 177 178 179
	primary: KeyCode.DownArrow,
	handler: (accessor, args: any) => {
		accessor.get(IInstantiationService).createInstance(searchActions.FocusNextInputAction, searchActions.FocusNextInputAction.ID, '').run();
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: searchActions.FocusPreviousInputAction.ID,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
180
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.InputBoxFocusedKey, Constants.SearchInputBoxFocusedKey.toNegated()),
S
Sandeep Somavarapu 已提交
181 182 183 184 185 186
	primary: KeyCode.UpArrow,
	handler: (accessor, args: any) => {
		accessor.get(IInstantiationService).createInstance(searchActions.FocusPreviousInputAction, searchActions.FocusPreviousInputAction.ID, '').run();
	}
});

187
CommandsRegistry.registerCommand(FindInFolderAction.ID, findInFolderCommand);
188

E
Erich Gamma 已提交
189 190 191 192 193 194 195 196 197 198 199 200
class ExplorerViewerActionContributor extends ActionBarContributor {
	private _instantiationService: IInstantiationService;

	constructor( @IInstantiationService instantiationService: IInstantiationService, @IWorkspaceContextService contextService: IWorkspaceContextService) {
		super();

		this._instantiationService = instantiationService;
	}

	public hasSecondaryActions(context: any): boolean {
		let element = context.element;

201 202 203 204 205
		// Contribute only on file resources and model (context menu for multi root)
		if (element instanceof Model) {
			return true;
		}

206
		let fileResource = explorerItemToFileResource(element);
E
Erich Gamma 已提交
207 208 209 210
		if (!fileResource) {
			return false;
		}

I
isidor 已提交
211
		return fileResource.isDirectory && fileResource.resource.scheme === 'file';
E
Erich Gamma 已提交
212 213 214 215 216 217
	}

	public getSecondaryActions(context: any): IAction[] {
		let actions: IAction[] = [];

		if (this.hasSecondaryActions(context)) {
218 219
			let action: Action;
			if (context.element instanceof Model) {
220
				action = this._instantiationService.createInstance(FindInWorkspaceAction);
221 222
			} else {
				let fileResource = explorerItemToFileResource(context.element);
223
				action = this._instantiationService.createInstance(FindInFolderAction, fileResource.resource);
224
			}
E
Erich Gamma 已提交
225 226 227 228 229 230 231 232 233 234 235 236

			action.order = 55;
			actions.push(action);

			actions.push(new Separator('', 56));
		}

		return actions;
	}
}

const ACTION_ID = 'workbench.action.showAllSymbols';
B
Benjamin Pasero 已提交
237
const ACTION_LABEL = nls.localize('showTriggerActions', "Go to Symbol in Workspace...");
E
Erich Gamma 已提交
238 239
const ALL_SYMBOLS_PREFIX = '#';

240
class ShowAllSymbolsAction extends Action {
E
Erich Gamma 已提交
241

242 243 244 245 246 247 248 249 250 251 252 253
	constructor(
		actionId: string, actionLabel: string,
		@IQuickOpenService private quickOpenService: IQuickOpenService,
		@ICodeEditorService private editorService: ICodeEditorService) {
		super(actionId, actionLabel);
		this.enabled = !!this.quickOpenService;
	}

	public run(context?: any): TPromise<void> {

		let prefix = ALL_SYMBOLS_PREFIX;
		let inputSelection: { start: number; end: number; } = void 0;
254 255
		let editor = this.editorService.getFocusedCodeEditor();
		const word = editor && getSelectionSearchString(editor);
256 257 258 259
		if (word) {
			prefix = prefix + word;
			inputSelection = { start: 1, end: word.length + 1 };
		}
E
Erich Gamma 已提交
260

261 262 263
		this.quickOpenService.show(prefix, { inputSelection });

		return TPromise.as(null);
E
Erich Gamma 已提交
264 265 266 267
	}
}

// Register Viewlet
B
Benjamin Pasero 已提交
268
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
269
	SearchViewlet,
270
	Constants.VIEWLET_ID,
E
Erich Gamma 已提交
271 272 273 274 275
	nls.localize('name', "Search"),
	'search',
	10
));

S
Sandeep Somavarapu 已提交
276
// Actions
B
Benjamin Pasero 已提交
277
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
B
Benjamin Pasero 已提交
278
const category = nls.localize('search', "Search");
E
Erich Gamma 已提交
279

R
Rob Lourens 已提交
280 281
// "Show Search" and "Find in Files" are redundant, but we will inevitably break keybindings if we remove one
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.FindInFilesAction, Constants.VIEWLET_ID, searchActions.SHOW_SEARCH_LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F },
282
	ContextKeyExpr.and(Constants.SearchViewletVisibleKey.toNegated(), EditorContextKeys.focus.toNegated())), 'View: Show Search', nls.localize('view', "View"));
283 284 285 286 287 288 289 290 291
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.FindInFilesAction, Constants.FindInFilesActionId, searchActions.FindInFilesAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F },
	ContextKeyExpr.and(Constants.SearchInputBoxFocusedKey.toNegated(), EditorContextKeys.focus.toNegated())), 'Find in Files', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ReplaceInFilesAction, searchActions.ReplaceInFilesAction.ID, searchActions.ReplaceInFilesAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_H },
	EditorContextKeys.focus.toNegated()), 'Replace in Files', category);

registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.FindInFilesWithSelectedTextAction, searchActions.FindInFilesWithSelectedTextAction.ID, searchActions.FindInFilesWithSelectedTextAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F },
	EditorContextKeys.focus), 'Find in Files With Selected Text', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ReplaceInFilesWithSelectedTextAction, searchActions.ReplaceInFilesWithSelectedTextAction.ID, searchActions.ReplaceInFilesWithSelectedTextAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_H },
	EditorContextKeys.focus), 'Replace in Files With Selected Text', category);
S
Sandeep Somavarapu 已提交
292

293 294 295 296 297 298 299 300
KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: Constants.FocusActiveEditorCommandId,
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.SearchInputBoxFocusedKey),
	handler: searchActions.FocusActiveEditorCommand,
	primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F
});

B
Benjamin Pasero 已提交
301 302
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.FocusNextSearchResultAction, searchActions.FocusNextSearchResultAction.ID, searchActions.FocusNextSearchResultAction.LABEL, { primary: KeyCode.F4 }), 'Focus Next Search Result', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.FocusPreviousSearchResultAction, searchActions.FocusPreviousSearchResultAction.ID, searchActions.FocusPreviousSearchResultAction.LABEL, { primary: KeyMod.Shift | KeyCode.F4 }), 'Focus Previous Search Result', category);
303

S
Sandeep Somavarapu 已提交
304 305 306 307
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.RefreshAction, searchActions.RefreshAction.ID, searchActions.RefreshAction.LABEL), 'Refresh', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.CollapseDeepestExpandedLevelAction, searchActions.CollapseDeepestExpandedLevelAction.ID, searchActions.CollapseDeepestExpandedLevelAction.LABEL), 'Collapse All', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ClearSearchResultsAction, searchActions.ClearSearchResultsAction.ID, searchActions.ClearSearchResultsAction.LABEL), 'Clear', category);

R
Rob Lourens 已提交
308
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
R
Rob Lourens 已提交
309
	id: Constants.ToggleCaseSensitiveCommandId,
R
Rob Lourens 已提交
310 311 312 313 314 315
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.SearchInputBoxFocusedKey),
	handler: searchActions.toggleCaseSensitiveCommand
}, ToggleCaseSensitiveKeybinding));

KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
R
Rob Lourens 已提交
316
	id: Constants.ToggleWholeWordCommandId,
R
Rob Lourens 已提交
317 318 319 320 321 322
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.SearchInputBoxFocusedKey),
	handler: searchActions.toggleWholeWordCommand
}, ToggleWholeWordKeybinding));

KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
R
Rob Lourens 已提交
323
	id: Constants.ToggleRegexCommandId,
R
Rob Lourens 已提交
324 325 326 327
	weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
	when: ContextKeyExpr.and(Constants.SearchViewletVisibleKey, Constants.SearchInputBoxFocusedKey),
	handler: searchActions.toggleRegexCommand
}, ToggleRegexKeybinding));
S
Sandeep Somavarapu 已提交
328

S
Sandeep Somavarapu 已提交
329
// Terms navigation actions
B
Benjamin Pasero 已提交
330 331
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ShowNextSearchTermAction, searchActions.ShowNextSearchTermAction.ID, searchActions.ShowNextSearchTermAction.LABEL, ShowNextFindTermKeybinding, searchActions.ShowNextSearchTermAction.CONTEXT_KEY_EXPRESSION), 'Search: Show Next Search Term', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ShowPreviousSearchTermAction, searchActions.ShowPreviousSearchTermAction.ID, searchActions.ShowPreviousSearchTermAction.LABEL, ShowPreviousFindTermKeybinding, searchActions.ShowPreviousSearchTermAction.CONTEXT_KEY_EXPRESSION), 'Search: Show Previous Search Term', category);
S
Sandeep Somavarapu 已提交
332

B
Benjamin Pasero 已提交
333 334
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ShowNextSearchIncludeAction, searchActions.ShowNextSearchIncludeAction.ID, searchActions.ShowNextSearchIncludeAction.LABEL, ShowNextFindTermKeybinding, searchActions.ShowNextSearchIncludeAction.CONTEXT_KEY_EXPRESSION), 'Search: Show Next Search Include Pattern', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ShowPreviousSearchIncludeAction, searchActions.ShowPreviousSearchIncludeAction.ID, searchActions.ShowPreviousSearchIncludeAction.LABEL, ShowPreviousFindTermKeybinding, searchActions.ShowPreviousSearchIncludeAction.CONTEXT_KEY_EXPRESSION), 'Search: Show Previous Search Include Pattern', category);
S
Sandeep Somavarapu 已提交
335

B
Benjamin Pasero 已提交
336 337
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ShowNextSearchExcludeAction, searchActions.ShowNextSearchExcludeAction.ID, searchActions.ShowNextSearchExcludeAction.LABEL, ShowNextFindTermKeybinding, searchActions.ShowNextSearchExcludeAction.CONTEXT_KEY_EXPRESSION), 'Search: Show Next Search Exclude Pattern', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ShowPreviousSearchExcludeAction, searchActions.ShowPreviousSearchExcludeAction.ID, searchActions.ShowPreviousSearchExcludeAction.LABEL, ShowPreviousFindTermKeybinding, searchActions.ShowPreviousSearchExcludeAction.CONTEXT_KEY_EXPRESSION), 'Search: Show Previous Search Exclude Pattern', category);
S
Sandeep Somavarapu 已提交
338

S
Sandeep Somavarapu 已提交
339
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowAllSymbolsAction, ACTION_ID, ACTION_LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_T }), 'Go to Symbol in Workspace...');
S
Sandeep Somavarapu 已提交
340

E
Erich Gamma 已提交
341
// Contribute to Explorer Viewer
B
Benjamin Pasero 已提交
342
const actionBarRegistry = Registry.as<IActionBarRegistry>(ActionBarExtensions.Actionbar);
E
Erich Gamma 已提交
343 344 345
actionBarRegistry.registerActionBarContributor(Scope.VIEWER, ExplorerViewerActionContributor);

// Register Quick Open Handler
B
Benjamin Pasero 已提交
346
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerDefaultQuickOpenHandler(
E
Erich Gamma 已提交
347
	new QuickOpenHandlerDescriptor(
348 349
		OpenAnythingHandler,
		OpenAnythingHandler.ID,
E
Erich Gamma 已提交
350
		'',
351
		defaultQuickOpenContextKey,
B
Benjamin Pasero 已提交
352
		nls.localize('openAnythingHandlerDescription', "Go to File")
E
Erich Gamma 已提交
353 354 355
	)
);

B
Benjamin Pasero 已提交
356
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
357
	new QuickOpenHandlerDescriptor(
358 359
		OpenSymbolHandler,
		OpenSymbolHandler.ID,
360
		ALL_SYMBOLS_PREFIX,
361
		'inWorkspaceSymbolsPicker',
362 363 364 365
		[
			{
				prefix: ALL_SYMBOLS_PREFIX,
				needsEditor: false,
B
Benjamin Pasero 已提交
366
				description: nls.localize('openSymbolDescriptionNormal', "Go to Symbol in Workspace")
367 368 369 370 371
			}
		]
	)
);

372 373 374 375
// Search output channel
const outputChannelRegistry = <IOutputChannelRegistry>Registry.as(OutputExt.OutputChannels);
outputChannelRegistry.registerChannel('search', nls.localize('searchOutputChannelTitle', "Search"));

E
Erich Gamma 已提交
376
// Configuration
B
Benjamin Pasero 已提交
377
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
E
Erich Gamma 已提交
378 379
configurationRegistry.registerConfiguration({
	'id': 'search',
380
	'order': 13,
381
	'title': nls.localize('searchConfigurationTitle', "Search"),
E
Erich Gamma 已提交
382 383 384 385
	'type': 'object',
	'properties': {
		'search.exclude': {
			'type': 'object',
386
			'description': nls.localize('exclude', "Configure glob patterns for excluding files and folders in searches. Inherits all glob patterns from the files.exclude setting."),
E
Erich Gamma 已提交
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
			'default': { '**/node_modules': true, '**/bower_components': true },
			'additionalProperties': {
				'anyOf': [
					{
						'type': 'boolean',
						'description': nls.localize('exclude.boolean', "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."),
					},
					{
						'type': 'object',
						'properties': {
							'when': {
								'type': 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })
								'pattern': '\\w*\\$\\(basename\\)\\w*',
								'default': '$(basename).ext',
								'description': nls.localize('exclude.when', 'Additional check on the siblings of a matching file. Use $(basename) as variable for the matching file name.')
							}
						}
					}
				]
S
Sandeep Somavarapu 已提交
406
			},
S
Sandeep Somavarapu 已提交
407
			'scope': ConfigurationScope.RESOURCE
408
		},
409 410
		'search.useRipgrep': {
			'type': 'boolean',
411
			'description': nls.localize('useRipgrep', "Controls whether to use ripgrep in text and file search"),
R
Rob Lourens 已提交
412
			'default': true
413
		},
414 415 416
		'search.useIgnoreFiles': {
			'type': 'boolean',
			'description': nls.localize('useIgnoreFiles', "Controls whether to use .gitignore and .ignore files when searching for files."),
417
			'default': true,
418 419
			'scope': ConfigurationScope.RESOURCE
		},
420 421
		'search.quickOpen.includeSymbols': {
			'type': 'boolean',
422
			'description': nls.localize('search.quickOpen.includeSymbols', "Configure to include results from a global symbol search in the file results for Quick Open."),
423
			'default': false
424 425 426 427 428
		},
		'search.followSymlinks': {
			'type': 'boolean',
			'description': nls.localize('search.followSymlinks', "Controls whether to follow symlinks while searching."),
			'default': true
E
Erich Gamma 已提交
429 430
		}
	}
J
Johannes Rieken 已提交
431
});
432

433
registerLanguageCommand('_executeWorkspaceSymbolProvider', function (accessor, args: { query: string; }) {
434 435 436 437 438 439
	let { query } = args;
	if (typeof query !== 'string') {
		throw illegalArgument();
	}
	return getWorkspaceSymbols(query);
});