searchActions.ts 18.1 KB
Newer Older
S
Sandeep Somavarapu 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import nls = require('vs/nls');
7
import DOM = require('vs/base/browser/dom');
S
Sandeep Somavarapu 已提交
8 9 10 11 12
import errors = require('vs/base/common/errors');
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';
B
Benjamin Pasero 已提交
13
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
S
Sandeep Somavarapu 已提交
14
import { ITree } from 'vs/base/parts/tree/browser/tree';
S
Sandeep Somavarapu 已提交
15
import { INavigator } from 'vs/base/common/iterator';
S
Sandeep Somavarapu 已提交
16
import { SearchViewlet } from 'vs/workbench/parts/search/browser/searchViewlet';
17 18
import { SearchResult, Match, FileMatch, FileMatchOrMatch } from 'vs/workbench/parts/search/common/searchModel';
import { IReplaceService } from 'vs/workbench/parts/search/common/replace';
S
Sandeep Somavarapu 已提交
19 20
import * as Constants from 'vs/workbench/parts/search/common/constants';
import { CollapseAllAction as TreeCollapseAction } from 'vs/base/parts/tree/browser/treeDefaults';
21
import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences';
22
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
23
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
24
import { Keybinding, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
25
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
26
import { toResource } from 'vs/workbench/common/editor';
27 28 29
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IListService } from 'vs/platform/list/browser/listService';
import { explorerItemToFileResource } from 'vs/workbench/parts/files/common/files';
B
Benjamin Pasero 已提交
30
import { IWorkspaceContextService } from "vs/platform/workspace/common/workspace";
S
Sandeep Somavarapu 已提交
31

S
Sandeep Somavarapu 已提交
32 33 34
export function isSearchViewletFocussed(viewletService: IViewletService): boolean {
	let activeViewlet = viewletService.getActiveViewlet();
	let activeElement = document.activeElement;
35 36 37
	return activeViewlet && activeViewlet.getId() === Constants.VIEWLET_ID && activeElement && DOM.isAncestor(activeElement, (<SearchViewlet>activeViewlet).getContainer().getHTMLElement());
}

E
Erich Gamma 已提交
38 39
export function appendKeyBindingLabel(label: string, keyBinding: Keybinding, keyBindingService2: IKeybindingService): string;
export function appendKeyBindingLabel(label: string, keyBinding: number, keyBindingService2: IKeybindingService): string;
S
Sandeep Somavarapu 已提交
40 41
export function appendKeyBindingLabel(label: string, keyBinding: any, keyBindingService2: IKeybindingService): string {
	keyBinding = typeof keyBinding === 'number' ? new Keybinding(keyBinding) : keyBinding;
S
Sandeep Somavarapu 已提交
42
	return keyBinding ? label + ' (' + keyBindingService2.getLabelFor(keyBinding) + ')' : label;
43 44
}

S
Sandeep Somavarapu 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
export class ToggleCaseSensitiveAction extends Action {

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		let searchViewlet = <SearchViewlet>this.viewletService.getActiveViewlet();
		searchViewlet.toggleCaseSensitive();
		return TPromise.as(null);
	}
}

export class ToggleWholeWordAction extends Action {

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		let searchViewlet = <SearchViewlet>this.viewletService.getActiveViewlet();
		searchViewlet.toggleWholeWords();
		return TPromise.as(null);
	}
}

export class ToggleRegexAction extends Action {

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		let searchViewlet = <SearchViewlet>this.viewletService.getActiveViewlet();
		searchViewlet.toggleRegex();
		return TPromise.as(null);
	}
}

84 85
export class ShowNextSearchTermAction extends Action {

86
	public static ID = 'search.history.showNext';
87
	public static LABEL = nls.localize('nextSearchTerm', "Show Next Search Term");
88 89 90 91 92 93 94 95 96 97 98 99 100 101

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		let searchAndReplaceWidget = (<SearchViewlet>this.viewletService.getActiveViewlet()).searchAndReplaceWidget;
		searchAndReplaceWidget.showNextSearchTerm();
		return TPromise.as(null);
	}
}

export class ShowPreviousSearchTermAction extends Action {

102
	public static ID = 'search.history.showPrevious';
103
	public static LABEL = nls.localize('previousSearchTerm', "Show Previous Search Term");
104 105 106 107 108 109 110 111 112 113 114 115

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		let searchAndReplaceWidget = (<SearchViewlet>this.viewletService.getActiveViewlet()).searchAndReplaceWidget;
		searchAndReplaceWidget.showPreviousSearchTerm();
		return TPromise.as(null);
	}
}

116 117 118
export class FocusNextInputAction extends Action {

	public static ID = 'search.focus.nextInputBox';
119
	public static LABEL = nls.localize('focusNextInputBox', "Focus Next Input Box");
120 121 122 123 124 125 126 127 128 129 130 131 132

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		(<SearchViewlet>this.viewletService.getActiveViewlet()).focusNextInputBox();
		return TPromise.as(null);
	}
}

export class FocusPreviousInputAction extends Action {

S
Sandeep Somavarapu 已提交
133
	public static ID = 'search.focus.previousInputBox';
134
	public static LABEL = nls.localize('focusPreviousInputBox', "Focus Previous Input Box");
135 136 137 138 139 140 141 142 143 144 145

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		(<SearchViewlet>this.viewletService.getActiveViewlet()).focusPreviousInputBox();
		return TPromise.as(null);
	}
}

S
Sandeep Somavarapu 已提交
146 147 148 149 150
export class OpenSearchViewletAction extends ToggleViewletAction {

	constructor(id: string, label: string, @IViewletService viewletService: IViewletService, @IWorkbenchEditorService editorService: IWorkbenchEditorService) {
		super(id, label, Constants.VIEWLET_ID, viewletService, editorService);
	}
151

S
Sandeep Somavarapu 已提交
152 153
}

S
Sandeep Somavarapu 已提交
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
export class FocusActiveEditorAction extends Action {

	constructor(id: string, label: string, @IWorkbenchEditorService private editorService: IWorkbenchEditorService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		let editor = this.editorService.getActiveEditor();
		if (editor) {
			editor.focus();
		}
		return TPromise.as(true);
	}

}

export class FindInFilesAction extends Action {

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		return this.viewletService.openViewlet(Constants.VIEWLET_ID, true);
	}

}

S
Sandeep Somavarapu 已提交
182 183 184 185 186 187 188 189 190 191 192
export class ReplaceInFilesAction extends Action {

	public static ID = 'workbench.action.replaceInFiles';
	public static LABEL = nls.localize('replaceInFiles', "Replace in Files");

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		return this.viewletService.openViewlet(Constants.VIEWLET_ID, true).then((viewlet) => {
S
Sandeep Somavarapu 已提交
193
			let searchAndReplaceWidget = (<SearchViewlet>viewlet).searchAndReplaceWidget;
194 195
			searchAndReplaceWidget.toggleReplace(true);
			searchAndReplaceWidget.focus(false, true);
S
Sandeep Somavarapu 已提交
196 197 198 199
		});
	}
}

S
Sandeep Somavarapu 已提交
200 201 202 203 204 205 206 207 208 209 210 211 212 213
export class CloseReplaceAction extends Action {

	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
		super(id, label);
	}

	public run(): TPromise<any> {
		let searchAndReplaceWidget = (<SearchViewlet>this.viewletService.getActiveViewlet()).searchAndReplaceWidget;
		searchAndReplaceWidget.toggleReplace(false);
		searchAndReplaceWidget.focus();
		return TPromise.as(null);
	}
}

S
Sandeep Somavarapu 已提交
214 215
export class FindInFolderAction extends Action {

216 217
	public static ID = 'filesExplorer.findInFolder';

S
Sandeep Somavarapu 已提交
218 219
	private resource: URI;

220 221
	constructor(resource: URI, @IInstantiationService private instantiationService: IInstantiationService) {
		super(FindInFolderAction.ID, nls.localize('findInFolder', "Find in Folder"));
S
Sandeep Somavarapu 已提交
222 223 224 225 226

		this.resource = resource;
	}

	public run(event?: any): TPromise<any> {
227
		return this.instantiationService.invokeFunction.apply(this.instantiationService, [findInFolderCommand, this.resource]);
S
Sandeep Somavarapu 已提交
228 229 230
	}
}

231 232 233
export const findInFolderCommand = (accessor: ServicesAccessor, resource?: URI) => {
	const listService = accessor.get(IListService);
	const viewletService = accessor.get(IViewletService);
B
Benjamin Pasero 已提交
234
	const contextService = accessor.get(IWorkspaceContextService);
235 236 237 238 239 240 241 242 243 244 245

	if (!URI.isUri(resource)) {
		const focused = listService.getFocused() ? listService.getFocused().getFocus() : void 0;
		if (focused) {
			const file = explorerItemToFileResource(focused);
			if (file && file.isDirectory) {
				resource = file.resource;
			}
		}
	}

B
Benjamin Pasero 已提交
246 247 248 249
	if (!URI.isUri(resource) && contextService.hasWorkspace()) {
		resource = contextService.getWorkspace().resource;
	}

250 251 252 253 254 255 256
	if (URI.isUri(resource)) {
		viewletService.openViewlet(Constants.VIEWLET_ID, true).then((viewlet: SearchViewlet) => {
			viewlet.searchInFolder(resource);
		}).done(null, errors.onUnexpectedError);
	}
};

S
Sandeep Somavarapu 已提交
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
export class RefreshAction extends Action {

	constructor(private viewlet: SearchViewlet) {
		super('refresh');

		this.label = nls.localize('RefreshAction.label', "Refresh");
		this.enabled = false;
		this.class = 'search-action refresh';
	}

	public run(): TPromise<void> {
		this.viewlet.onQueryChanged(true);

		return TPromise.as(null);
	}
}

export class CollapseAllAction extends TreeCollapseAction {

	constructor(viewlet: SearchViewlet) {
		super(viewlet.getControl(), false);
		this.class = 'search-action collapse';
	}
}

export class ClearSearchResultsAction extends Action {

	constructor(private viewlet: SearchViewlet) {
		super('clearSearchResults');

		this.label = nls.localize('ClearSearchResultsAction.label', "Clear Search Results");
		this.enabled = false;
		this.class = 'search-action clear-search-results';
	}

	public run(): TPromise<void> {
		this.viewlet.clearSearchResults();

		return TPromise.as(null);
	}
}

299
export class FocusNextSearchResultAction extends Action {
R
roblou 已提交
300
	public static ID = 'search.action.focusNextSearchResult';
R
Rob Lourens 已提交
301
	public static LABEL = nls.localize('FocusNextSearchResult.label', "Focus Next Search Result");
R
roblou 已提交
302

303
	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
R
roblou 已提交
304
		super(id, label);
305 306 307 308
	}

	public run(): TPromise<any> {
		return this.viewletService.openViewlet(Constants.VIEWLET_ID).then((searchViewlet: SearchViewlet) => {
R
Rob Lourens 已提交
309
			searchViewlet.selectNextMatch();
310 311 312 313 314
		});
	}
}

export class FocusPreviousSearchResultAction extends Action {
R
roblou 已提交
315
	public static ID = 'search.action.focusPreviousSearchResult';
R
Rob Lourens 已提交
316
	public static LABEL = nls.localize('FocusPreviousSearchResult.label', "Focus Previous Search Result");
R
roblou 已提交
317

318
	constructor(id: string, label: string, @IViewletService private viewletService: IViewletService) {
R
roblou 已提交
319
		super(id, label);
320 321 322 323
	}

	public run(): TPromise<any> {
		return this.viewletService.openViewlet(Constants.VIEWLET_ID).then((searchViewlet: SearchViewlet) => {
R
Rob Lourens 已提交
324
			searchViewlet.selectPreviousMatch();
325 326 327 328
		});
	}
}

S
Sandeep Somavarapu 已提交
329 330
export abstract class AbstractSearchAndReplaceAction extends Action {

S
Sandeep Somavarapu 已提交
331 332 333
	/**
	 * Returns element to focus after removing the given element
	 */
S
Sandeep Somavarapu 已提交
334
	public getElementToFocusAfterRemoved(viewer: ITree, elementToBeRemoved: FileMatchOrMatch): FileMatchOrMatch {
S
Sandeep Somavarapu 已提交
335 336 337 338 339 340
		let elementToFocus = this.getNextElementAfterRemoved(viewer, elementToBeRemoved);
		if (!elementToFocus) {
			elementToFocus = this.getPreviousElementAfterRemoved(viewer, elementToBeRemoved);
		}
		return elementToFocus;
	}
S
Sandeep Somavarapu 已提交
341

S
Sandeep Somavarapu 已提交
342
	public getNextElementAfterRemoved(viewer: ITree, element: FileMatchOrMatch): FileMatchOrMatch {
S
Sandeep Somavarapu 已提交
343 344 345 346 347 348 349 350 351
		let navigator: INavigator<any> = this.getNavigatorAt(element, viewer);
		if (element instanceof FileMatch) {
			// If file match is removed then next element is the next file match
			while (!!navigator.next() && !(navigator.current() instanceof FileMatch)) { };
		} else {
			navigator.next();
		}
		return navigator.current();
	}
S
Sandeep Somavarapu 已提交
352

S
Sandeep Somavarapu 已提交
353
	public getPreviousElementAfterRemoved(viewer: ITree, element: FileMatchOrMatch): FileMatchOrMatch {
S
Sandeep Somavarapu 已提交
354 355 356 357 358 359
		let navigator: INavigator<any> = this.getNavigatorAt(element, viewer);
		let previousElement = navigator.previous();
		if (element instanceof Match && element.parent().matches().length === 1) {
			// If this is the only match, then the file match is also removed
			// Hence take the previous element to file match
			previousElement = navigator.previous();
S
Sandeep Somavarapu 已提交
360
		}
S
Sandeep Somavarapu 已提交
361 362 363 364
		return previousElement;
	}

	private getNavigatorAt(element: FileMatchOrMatch, viewer: ITree): INavigator<any> {
J
Johannes Rieken 已提交
365
		let navigator: INavigator<any> = viewer.getNavigator();
S
Sandeep Somavarapu 已提交
366
		while (navigator.current() !== element && !!navigator.next()) { }
S
Sandeep Somavarapu 已提交
367
		return navigator;
S
Sandeep Somavarapu 已提交
368 369 370 371
	}
}

export class RemoveAction extends AbstractSearchAndReplaceAction {
S
Sandeep Somavarapu 已提交
372

373 374
	constructor(private viewer: ITree, private element: FileMatchOrMatch) {
		super('remove', nls.localize('RemoveAction.label', "Remove"), 'action-remove');
S
Sandeep Somavarapu 已提交
375 376
	}

377
	public run(): TPromise<any> {
S
Sandeep Somavarapu 已提交
378
		let nextFocusElement = this.getElementToFocusAfterRemoved(this.viewer, this.element);
S
Sandeep Somavarapu 已提交
379 380
		if (nextFocusElement) {
			this.viewer.setFocus(nextFocusElement);
381 382
		}

383
		let elementToRefresh: any;
384
		if (this.element instanceof FileMatch) {
S
Sandeep Somavarapu 已提交
385
			let parent: SearchResult = <SearchResult>this.element.parent();
386
			parent.remove(<FileMatch>this.element);
S
Sandeep Somavarapu 已提交
387
			elementToRefresh = parent;
S
Sandeep Somavarapu 已提交
388
		} else {
S
Sandeep Somavarapu 已提交
389
			let parent: FileMatch = <FileMatch>this.element.parent();
390
			parent.remove(<Match>this.element);
S
Sandeep Somavarapu 已提交
391
			elementToRefresh = parent.count() === 0 ? parent.parent() : parent;
S
Sandeep Somavarapu 已提交
392
		}
393

S
Sandeep Somavarapu 已提交
394
		this.viewer.DOMFocus();
395 396 397
		return this.viewer.refresh(elementToRefresh);
	}

398
}
S
Sandeep Somavarapu 已提交
399

S
Sandeep Somavarapu 已提交
400
export class ReplaceAllAction extends AbstractSearchAndReplaceAction {
S
Sandeep Somavarapu 已提交
401

402
	public static get KEY_BINDING(): number {
A
Alexandru Dima 已提交
403
		return KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter;
404 405
	}

406
	constructor(private viewer: ITree, private fileMatch: FileMatch, private viewlet: SearchViewlet,
S
Sandeep Somavarapu 已提交
407 408 409
		@IReplaceService private replaceService: IReplaceService,
		@IKeybindingService keyBindingService2: IKeybindingService,
		@ITelemetryService private telemetryService: ITelemetryService) {
A
Alex Dima 已提交
410
		super('file-action-replace-all', appendKeyBindingLabel(nls.localize('file.replaceAll.label', "Replace All"), ReplaceAllAction.KEY_BINDING, keyBindingService2), 'action-replace-all');
S
Sandeep Somavarapu 已提交
411 412
	}

413
	public run(): TPromise<any> {
414
		this.telemetryService.publicLog('replaceAll.action.selected');
S
Sandeep Somavarapu 已提交
415
		let nextFocusElement = this.getElementToFocusAfterRemoved(this.viewer, this.fileMatch);
S
Sandeep Somavarapu 已提交
416
		return this.fileMatch.parent().replace(this.fileMatch).then(() => {
S
Sandeep Somavarapu 已提交
417 418 419 420 421
			if (nextFocusElement) {
				this.viewer.setFocus(nextFocusElement);
			}
			this.viewer.DOMFocus();
			this.viewlet.open(this.fileMatch, true);
S
Sandeep Somavarapu 已提交
422 423 424 425
		});
	}
}

S
Sandeep Somavarapu 已提交
426
export class ReplaceAction extends AbstractSearchAndReplaceAction {
S
Sandeep Somavarapu 已提交
427

428 429 430 431
	public static get KEY_BINDING(): number {
		return KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.KEY_1;
	}

432
	constructor(private viewer: ITree, private element: Match, private viewlet: SearchViewlet,
S
Sandeep Somavarapu 已提交
433 434 435 436
		@IReplaceService private replaceService: IReplaceService,
		@IKeybindingService keyBindingService2: IKeybindingService,
		@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
		@ITelemetryService private telemetryService: ITelemetryService) {
A
Alex Dima 已提交
437
		super('action-replace', appendKeyBindingLabel(nls.localize('match.replace.label', "Replace"), ReplaceAction.KEY_BINDING, keyBindingService2), 'action-replace');
S
Sandeep Somavarapu 已提交
438 439 440
	}

	public run(): TPromise<any> {
S
Sandeep Somavarapu 已提交
441
		this.enabled = false;
442
		this.telemetryService.publicLog('replace.action.selected');
S
Sandeep Somavarapu 已提交
443

S
Sandeep Somavarapu 已提交
444
		return this.element.parent().replace(this.element).then(() => {
S
Sandeep Somavarapu 已提交
445
			let elementToFocus = this.getElementToFocusAfterReplace();
S
Sandeep Somavarapu 已提交
446 447
			if (elementToFocus) {
				this.viewer.setFocus(elementToFocus);
S
Sandeep Somavarapu 已提交
448
			}
S
Sandeep Somavarapu 已提交
449
			let elementToShowReplacePreview = this.getElementToShowReplacePreview(elementToFocus);
S
Sandeep Somavarapu 已提交
450
			this.viewer.DOMFocus();
S
Sandeep Somavarapu 已提交
451 452
			if (!elementToShowReplacePreview || this.hasToOpenFile()) {
				this.viewlet.open(this.element, true);
S
Sandeep Somavarapu 已提交
453
			} else {
S
Sandeep Somavarapu 已提交
454
				this.replaceService.openReplacePreview(elementToShowReplacePreview, true);
S
Sandeep Somavarapu 已提交
455
			}
456
		});
S
Sandeep Somavarapu 已提交
457
	}
S
Sandeep Somavarapu 已提交
458

S
Sandeep Somavarapu 已提交
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
	private getElementToFocusAfterReplace(): Match {
		let navigator: INavigator<any> = this.viewer.getNavigator();
		let fileMatched = false;
		let elementToFocus = null;
		do {
			elementToFocus = navigator.current();
			if (elementToFocus instanceof Match) {
				if (elementToFocus.parent().id() === this.element.parent().id()) {
					fileMatched = true;
					if (this.element.range().getStartPosition().isBeforeOrEqual((<Match>elementToFocus).range().getStartPosition())) {
						// Closest next match in the same file
						break;
					}
				} else if (fileMatched) {
					// First match in the next file (if expanded)
					break;
				}
			} else if (fileMatched) {
				if (!this.viewer.isExpanded(elementToFocus)) {
					// Next file match (if collapsed)
					break;
				}
			}
		} while (!!navigator.next());
		return elementToFocus;
	}

S
Sandeep Somavarapu 已提交
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
	private getElementToShowReplacePreview(elementToFocus: FileMatchOrMatch): Match {
		if (this.hasSameParent(elementToFocus)) {
			return <Match>elementToFocus;
		}
		let previousElement = this.getPreviousElementAfterRemoved(this.viewer, this.element);
		if (this.hasSameParent(previousElement)) {
			return <Match>previousElement;
		}
		return null;
	}

	private hasSameParent(element: FileMatchOrMatch): boolean {
		return element && element instanceof Match && element.parent().resource() === this.element.parent().resource();
	}

	private hasToOpenFile(): boolean {
502 503 504
		const file = toResource(this.editorService.getActiveEditorInput(), { filter: 'file' });
		if (file) {
			return file.fsPath === this.element.parent().resource().fsPath;
S
Sandeep Somavarapu 已提交
505 506 507
		}
		return false;
	}
S
Sandeep Somavarapu 已提交
508 509 510 511
}

export class ConfigureGlobalExclusionsAction extends Action {

512
	constructor( @IPreferencesService private preferencesService: IPreferencesService) {
S
Sandeep Somavarapu 已提交
513 514 515 516 517 518 519 520
		super('configureGlobalExclusionsAction');

		this.label = nls.localize('ConfigureGlobalExclusionsAction.label', "Open Settings");
		this.enabled = true;
		this.class = 'search-configure-exclusions';
	}

	public run(): TPromise<void> {
521
		return this.preferencesService.openGlobalSettings().then(null, errors.onUnexpectedError);
S
Sandeep Somavarapu 已提交
522 523
	}
}