VSCode merge (#4610)

* Merge from vscode e388c734f30757875976c7e326d6cfeee77710de

* fix yarn lcoks

* remove small issue
This commit is contained in:
Anthony Dresser
2019-03-20 10:39:09 -07:00
committed by GitHub
parent 87765e8673
commit c814b92557
310 changed files with 6606 additions and 2129 deletions

View File

@@ -393,6 +393,6 @@
line-height: 20px;
}
.vs .panel .search-view .monaco-inputbox {
.vs .search-panel .search-view .monaco-inputbox {
border: 1px solid #ddd;
}

View File

@@ -3,13 +3,10 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/search.contribution';
import { Action } from 'vs/base/common/actions';
import { distinct } from 'vs/base/common/arrays';
import { illegalArgument } from 'vs/base/common/errors';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Schemas } from 'vs/base/common/network';
import * as objects from 'vs/base/common/objects';
import * as platform from 'vs/base/common/platform';
import { dirname } from 'vs/base/common/resources';
@@ -32,32 +29,31 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IListService, WorkbenchListFocusContextKey, WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { Registry } from 'vs/platform/registry/common/platform';
import { ISearchConfigurationProperties, ISearchConfiguration, VIEWLET_ID, PANEL_ID, VIEW_ID, VIEW_CONTAINER } from 'vs/workbench/services/search/common/search';
import { Extensions as PanelExtensions, PanelDescriptor, PanelRegistry } from 'vs/workbench/browser/panel';
import { defaultQuickOpenContextKey } from 'vs/workbench/browser/parts/quickopen/quickopen';
import { Extensions as QuickOpenExtensions, IQuickOpenRegistry, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
import { Extensions as ViewletExtensions, ViewletDescriptor, ViewletRegistry } from 'vs/workbench/browser/viewlet';
import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { ResourceContextKey } from 'vs/workbench/common/resources';
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 { 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';
import { clearHistoryCommand, ClearSearchResultsAction, CloseReplaceAction, CollapseDeepestExpandedLevelAction, copyAllCommand, copyMatchCommand, copyPathCommand, FindInFilesAction, FocusNextInputAction, FocusNextSearchResultAction, FocusPreviousInputAction, FocusPreviousSearchResultAction, focusSearchListCommand, getSearchView, openSearchView, OpenSearchViewletAction, RefreshAction, RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction, ReplaceInFilesAction, toggleCaseSensitiveCommand, toggleRegexCommand, toggleWholeWordCommand } from 'vs/workbench/contrib/search/browser/searchActions';
import { SearchPanel } from 'vs/workbench/contrib/search/browser/searchPanel';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import { SearchViewlet } from 'vs/workbench/contrib/search/browser/searchViewlet';
import { registerContributions as searchWidgetContributions } from 'vs/workbench/contrib/search/browser/searchWidget';
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 { 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 { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { ViewletDescriptor, ViewletRegistry, Extensions as ViewletExtensions } from 'vs/workbench/browser/viewlet';
import { ISearchHistoryService, SearchHistoryService } from 'vs/workbench/contrib/search/common/searchHistoryService';
import { SearchViewlet } from 'vs/workbench/contrib/search/browser/searchViewlet';
import { SearchPanel } from 'vs/workbench/contrib/search/browser/searchPanel';
import { IViewsRegistry, Extensions as ViewExtensions } from 'vs/workbench/common/views';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
registerSingleton(ISearchWorkbenchService, SearchWorkbenchService, true);
registerSingleton(ISearchHistoryService, SearchHistoryService, true);
@@ -365,15 +361,15 @@ const searchInFolderCommand: ICommandHandler = (accessor, resource?: URI) => {
const panelService = accessor.get(IPanelService);
const fileService = accessor.get(IFileService);
const configurationService = accessor.get(IConfigurationService);
const resources = getMultiSelectedResources(resource, listService, accessor.get(IEditorService));
const resources = resource && getMultiSelectedResources(resource, listService, accessor.get(IEditorService));
return openSearchView(viewletService, panelService, configurationService, true).then(searchView => {
if (resources && resources.length) {
if (resources && resources.length && searchView) {
return fileService.resolveFiles(resources.map(resource => ({ resource }))).then(results => {
const folders: URI[] = [];
results.forEach(result => {
if (result.success) {
if (result.success && result.stat) {
folders.push(result.stat.isDirectory ? result.stat.resource : dirname(result.stat.resource));
}
});
@@ -390,7 +386,7 @@ const FIND_IN_FOLDER_ID = 'filesExplorer.findInFolder';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: FIND_IN_FOLDER_ID,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerFolderContext, ResourceContextKey.Scheme.isEqualTo(Schemas.file)), // todo@remote
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerFolderContext),
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_F,
handler: searchInFolderCommand
});
@@ -414,7 +410,9 @@ CommandsRegistry.registerCommand({
id: FIND_IN_WORKSPACE_ID,
handler: (accessor) => {
return openSearchView(accessor.get(IViewletService), accessor.get(IPanelService), accessor.get(IConfigurationService), true).then(searchView => {
searchView.searchInFolders(null);
if (searchView) {
searchView.searchInFolders();
}
});
}
});
@@ -426,7 +424,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
id: FIND_IN_FOLDER_ID,
title: nls.localize('findInFolder', "Find in Folder...")
},
when: ContextKeyExpr.and(ExplorerFolderContext, ResourceContextKey.Scheme.isEqualTo(Schemas.file)) // todo@remote
when: ContextKeyExpr.and(ExplorerFolderContext)
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
@@ -456,7 +454,7 @@ class ShowAllSymbolsAction extends Action {
run(context?: any): Promise<void> {
let prefix = ShowAllSymbolsAction.ALL_SYMBOLS_PREFIX;
let inputSelection: { start: number; end: number; } = undefined;
let inputSelection: { start: number; end: number; } | undefined = undefined;
const editor = this.editorService.getFocusedCodeEditor();
const word = editor && getSelectionSearchString(editor);
if (word) {

View File

@@ -52,14 +52,15 @@ export function appendKeyBindingLabel(label: string, inputKeyBinding: number | R
}
}
export function openSearchView(viewletService: IViewletService, panelService: IPanelService, configurationService: IConfigurationService, focus?: boolean): Promise<SearchView> {
export function openSearchView(viewletService: IViewletService, panelService: IPanelService, configurationService: IConfigurationService, focus?: boolean): Promise<SearchView | undefined> {
if (configurationService.getValue<ISearchConfiguration>().search.location === 'panel') {
return Promise.resolve((panelService.openPanel(PANEL_ID, focus) as SearchPanel).getSearchView());
}
return viewletService.openViewlet(VIEWLET_ID, focus).then(viewlet => (viewlet as SearchViewlet).getSearchView());
}
export function getSearchView(viewletService: IViewletService, panelService: IPanelService): SearchView | null {
export function getSearchView(viewletService: IViewletService, panelService: IPanelService): SearchView | undefined {
const activeViewlet = viewletService.getActiveViewlet();
if (activeViewlet && activeViewlet.getId() === VIEWLET_ID) {
return (activeViewlet as SearchViewlet).getSearchView();
@@ -149,11 +150,13 @@ export abstract class FindOrReplaceInFilesAction extends Action {
run(): Promise<any> {
return openSearchView(this.viewletService, this.panelService, this.configurationService, false).then(openedView => {
const searchAndReplaceWidget = openedView.searchAndReplaceWidget;
searchAndReplaceWidget.toggleReplace(this.expandSearchReplaceWidget);
if (openedView) {
const searchAndReplaceWidget = openedView.searchAndReplaceWidget;
searchAndReplaceWidget.toggleReplace(this.expandSearchReplaceWidget);
const updatedText = openedView.updateTextFromSelection(!this.expandSearchReplaceWidget);
openedView.searchAndReplaceWidget.focus(undefined, updatedText, updatedText);
const updatedText = openedView.updateTextFromSelection(!this.expandSearchReplaceWidget);
openedView.searchAndReplaceWidget.focus(undefined, updatedText, updatedText);
}
});
}
}
@@ -240,7 +243,7 @@ export class RefreshAction extends Action {
static readonly ID: string = 'search.action.refreshSearchResults';
static LABEL: string = nls.localize('RefreshAction.label', "Refresh");
private searchView: SearchView | null;
private searchView: SearchView | undefined;
constructor(id: string, label: string,
@IViewletService private readonly viewletService: IViewletService,
@@ -394,7 +397,9 @@ export class FocusNextSearchResultAction extends Action {
run(): Promise<any> {
return openSearchView(this.viewletService, this.panelService, this.configurationService).then(searchView => {
searchView.selectNextMatch();
if (searchView) {
searchView.selectNextMatch();
}
});
}
}
@@ -413,7 +418,9 @@ export class FocusPreviousSearchResultAction extends Action {
run(): Promise<any> {
return openSearchView(this.viewletService, this.panelService, this.configurationService).then(searchView => {
searchView.selectPreviousMatch();
if (searchView) {
searchView.selectPreviousMatch();
}
});
}
}
@@ -771,6 +778,8 @@ export const focusSearchListCommand: ICommandHandler = accessor => {
const panelService = accessor.get(IPanelService);
const configurationService = accessor.get(IConfigurationService);
openSearchView(viewletService, panelService, configurationService).then(searchView => {
searchView.moveFocusToResults();
if (searchView) {
searchView.moveFocusToResults();
}
});
};

View File

@@ -31,7 +31,7 @@ export class SearchPanel extends Panel {
}
create(parent: HTMLElement): void {
dom.addClass(parent, 'monaco-panel-view');
dom.addClasses(parent, 'monaco-panel-view', 'search-panel');
this.searchView.render();
dom.append(parent, this.searchView.element);
this.searchView.setExpanded(true);
@@ -64,7 +64,7 @@ export class SearchPanel extends Panel {
super.saveState();
}
getSearchView(): SearchView | null {
getSearchView(): SearchView {
return this.searchView;
}
}

View File

@@ -115,13 +115,13 @@ export class SearchView extends ViewletPanel {
private inputPatternIncludes: PatternInputWidget;
private resultsElement: HTMLElement;
private currentSelectedFileMatch: FileMatch;
private currentSelectedFileMatch: FileMatch | undefined;
private readonly selectCurrentMatchEmitter: Emitter<string | undefined>;
private delayedRefresh: Delayer<void>;
private changedWhileHidden: boolean;
private searchWithoutFolderMessageElement: HTMLElement;
private searchWithoutFolderMessageElement: HTMLElement | undefined;
private currentSearchQ = Promise.resolve();
@@ -474,7 +474,7 @@ export class SearchView extends ViewletPanel {
});
}
private createFolderIterator(folderMatch: FolderMatch, collapseResults: ISearchConfigurationProperties['collapseResults']): Iterator<ITreeElement<RenderableMatch>> {
private createFolderIterator(folderMatch: BaseFolderMatch, collapseResults: ISearchConfigurationProperties['collapseResults']): Iterator<ITreeElement<RenderableMatch>> {
const filesIt = Iterator.fromArray(
folderMatch.matches()
.sort(searchMatchComparer));
@@ -797,7 +797,7 @@ export class SearchView extends ViewletPanel {
updateTextFromSelection(allowUnselectedWord = true): boolean {
let updatedText = false;
const seedSearchStringFromSelection = this.configurationService.getValue<IEditorOptions>('editor').find.seedSearchStringFromSelection;
const seedSearchStringFromSelection = this.configurationService.getValue<IEditorOptions>('editor').find!.seedSearchStringFromSelection;
if (seedSearchStringFromSelection) {
let selectedText = this.getSearchTextFromEditor(allowUnselectedWord);
if (selectedText) {
@@ -1074,7 +1074,7 @@ export class SearchView extends ViewletPanel {
}
}
searchInFolders(resources: URI[]): void {
searchInFolders(resources?: URI[]): void {
const folderPaths: string[] = [];
const workspace = this.contextService.getWorkspace();
@@ -1338,7 +1338,7 @@ export class SearchView extends ViewletPanel {
const onError = (e: any) => {
if (errors.isPromiseCanceledError(e)) {
return onComplete(null);
return onComplete(undefined);
} else {
this.searching = false;
this.updateActions();
@@ -1422,7 +1422,7 @@ export class SearchView extends ViewletPanel {
this.openSettings('.exclude');
}
private openSettings(query: string): Promise<IEditor> {
private openSettings(query: string): Promise<IEditor | null> {
const options: ISettingsEditorOptions = { query };
return this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ?
this.preferencesService.openWorkspaceSettings(undefined, options) :
@@ -1480,7 +1480,7 @@ export class SearchView extends ViewletPanel {
const actionClass = env.isMacintosh ? OpenFileFolderAction : OpenFolderAction;
const action = this.instantiationService.createInstance<string, string, IAction>(actionClass, actionClass.ID, actionClass.LABEL);
this.actionRunner.run(action).then(() => {
this.actionRunner!.run(action).then(() => {
action.dispose();
}, err => {
action.dispose();
@@ -1499,7 +1499,7 @@ export class SearchView extends ViewletPanel {
// this.replaceService.disposeAllReplacePreviews();
dom.hide(this.messagesElement);
dom.show(this.resultsElement);
this.currentSelectedFileMatch = null;
this.currentSelectedFileMatch = undefined;
}
private onFocus(lineMatch: any, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<any> {
@@ -1514,7 +1514,7 @@ export class SearchView extends ViewletPanel {
this.open(lineMatch, preserveFocus, sideBySide, pinned);
}
open(element: FileMatchOrMatch, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<any> {
open(element: FileMatchOrMatch, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<void> {
const selection = this.getSelectionFrom(element);
const resource = element instanceof Match ? element.parent().resource() : (<FileMatch>element).resource();
return this.editorService.openEditor({
@@ -1528,7 +1528,7 @@ export class SearchView extends ViewletPanel {
}, sideBySide ? SIDE_GROUP : ACTIVE_GROUP).then(editor => {
if (editor && element instanceof Match && preserveFocus) {
this.viewModel.searchResult.rangeHighlightDecorations.highlightRange(
(<ICodeEditor>editor.getControl()).getModel(),
(<ICodeEditor>editor.getControl()).getModel()!,
element.range()
);
} else {
@@ -1536,9 +1536,7 @@ export class SearchView extends ViewletPanel {
}
if (editor) {
return this.editorGroupsService.activateGroup(editor.group);
} else {
return Promise.resolve(null);
this.editorGroupsService.activateGroup(editor.group!);
}
}, errors.onUnexpectedError);
}
@@ -1714,4 +1712,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
if (outlineSelectionColor) {
collector.addRule(`.monaco-workbench .search-view .monaco-list.element-focused .monaco-list-row.focused.selected:not(.highlighted) .action-label:focus { outline-color: ${outlineSelectionColor} }`);
}
});
});

View File

@@ -38,8 +38,8 @@ export class SearchViewlet extends ViewContainerViewlet {
return Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet(this.getId()).name;
}
getSearchView(): SearchView | null {
getSearchView(): SearchView | undefined {
const view = super.getView(VIEW_ID);
return view ? view as SearchView : null;
return view ? view as SearchView : undefined;
}
}

View File

@@ -56,7 +56,7 @@ class ReplaceAllAction extends Action {
return ReplaceAllAction.fgInstance;
}
private _searchWidget: SearchWidget | null = null;
private _searchWidget: SearchWidget;
constructor() {
super(ReplaceAllAction.ID, '', 'action-replace-all', false);
@@ -113,8 +113,8 @@ export class SearchWidget extends Widget {
private _onReplaceStateChange = this._register(new Emitter<boolean>());
readonly onReplaceStateChange: Event<boolean> = this._onReplaceStateChange.event;
private _onReplaceValueChanged = this._register(new Emitter<string | undefined>());
readonly onReplaceValueChanged: Event<string> = this._onReplaceValueChanged.event;
private _onReplaceValueChanged = this._register(new Emitter<void>());
readonly onReplaceValueChanged: Event<void> = this._onReplaceValueChanged.event;
private _onReplaceAll = this._register(new Emitter<void>());
readonly onReplaceAll: Event<void> = this._onReplaceAll.event;
@@ -343,7 +343,7 @@ export class SearchWidget extends Widget {
this._register(attachInputBoxStyler(this.replaceInput, this.themeService));
this.onkeydown(this.replaceInput.inputElement, (keyboardEvent) => this.onReplaceInputKeyDown(keyboardEvent));
this.replaceInput.value = options.replaceValue || '';
this._register(this.replaceInput.onDidChange(() => this._onReplaceValueChanged.fire(undefined)));
this._register(this.replaceInput.onDidChange(() => this._onReplaceValueChanged.fire()));
this._register(this.replaceInput.onDidHeightChange(() => this._onDidHeightChange.fire()));
this.replaceAllAction = ReplaceAllAction.INSTANCE;
@@ -532,8 +532,6 @@ export class SearchWidget extends Widget {
dispose(): void {
this.setReplaceAllActionState(false);
this.replaceAllAction.searchWidget = null;
this.replaceActionBar = null;
super.dispose();
}