Merge from vscode 112fa76c775ecb79ac2c9e9e5dba0d711d523543 (#6388)

This commit is contained in:
Anthony Dresser
2019-07-17 01:07:27 -07:00
committed by GitHub
parent 43bd7268e8
commit 2d73b6afb1
59 changed files with 652 additions and 638 deletions

View File

@@ -5,7 +5,7 @@
import { Action } from 'vs/base/common/actions';
import { distinct } from 'vs/base/common/arrays';
import { illegalArgument } from 'vs/base/common/errors';
import { illegalArgument, onUnexpectedError } from 'vs/base/common/errors';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import * as objects from 'vs/base/common/objects';
import * as platform from 'vs/base/common/platform';
@@ -38,7 +38,7 @@ import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/wor
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { Extensions as ViewExtensions, IViewsRegistry } from 'vs/workbench/common/views';
import { getMultiSelectedResources } from 'vs/workbench/contrib/files/browser/files';
import { ExplorerFolderContext, ExplorerRootContext, FilesExplorerFocusCondition } from 'vs/workbench/contrib/files/common/files';
import { ExplorerFolderContext, ExplorerRootContext, FilesExplorerFocusCondition, IExplorerService, VIEWLET_ID as VIEWLET_ID_FILES } from 'vs/workbench/contrib/files/common/files';
import { OpenAnythingHandler } from 'vs/workbench/contrib/search/browser/openAnythingHandler';
import { OpenSymbolHandler } from 'vs/workbench/contrib/search/browser/openSymbolHandler';
import { registerContributions as replaceContributions } from 'vs/workbench/contrib/search/browser/replaceContributions';
@@ -50,11 +50,13 @@ import { registerContributions as searchWidgetContributions } from 'vs/workbench
import * as Constants from 'vs/workbench/contrib/search/common/constants';
import { getWorkspaceSymbols } from 'vs/workbench/contrib/search/common/search';
import { ISearchHistoryService, SearchHistoryService } from 'vs/workbench/contrib/search/common/searchHistoryService';
import { FileMatchOrMatch, ISearchWorkbenchService, RenderableMatch, SearchWorkbenchService } from 'vs/workbench/contrib/search/common/searchModel';
import { FileMatchOrMatch, ISearchWorkbenchService, RenderableMatch, SearchWorkbenchService, FileMatch } from 'vs/workbench/contrib/search/common/searchModel';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ISearchConfiguration, ISearchConfigurationProperties, PANEL_ID, VIEWLET_ID, VIEW_CONTAINER, VIEW_ID } from 'vs/workbench/services/search/common/search';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ExplorerViewlet } from 'vs/workbench/contrib/files/browser/explorerViewlet';
registerSingleton(ISearchWorkbenchService, SearchWorkbenchService, true);
registerSingleton(ISearchHistoryService, SearchHistoryService, true);
@@ -211,6 +213,37 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
CommandsRegistry.registerCommand({
id: Constants.RevealInSideBarForSearchResults,
handler: (accessor, fileMatch: FileMatch) => {
const viewletService = accessor.get(IViewletService);
const explorerService = accessor.get(IExplorerService);
const contextService = accessor.get(IWorkspaceContextService);
const uri = fileMatch.resource();
viewletService.openViewlet(VIEWLET_ID_FILES, false).then((viewlet: ExplorerViewlet) => {
if (uri && contextService.isInsideWorkspace(uri)) {
const explorerView = viewlet.getExplorerView();
if (explorerView) {
explorerView.setExpanded(true);
explorerService.select(uri, true).then(() => explorerView.focus(), onUnexpectedError);
}
}
});
}
});
const RevealInSideBarForSearchResultsCommand: ICommandAction = {
id: Constants.RevealInSideBarForSearchResults,
title: nls.localize('revealInSideBar', "Reveal in Explorer")
};
MenuRegistry.appendMenuItem(MenuId.SearchContext, {
command: RevealInSideBarForSearchResultsCommand,
when: ContextKeyExpr.and(Constants.FileFocusKey, Constants.HasSearchResults),
group: '2_files',
});
MenuRegistry.appendMenuItem(MenuId.SearchContext, {
command: {
id: Constants.ReplaceActionId,