Merge VS Code 1.21 source code (#1067)

* Initial VS Code 1.21 file copy with patches

* A few more merges

* Post npm install

* Fix batch of build breaks

* Fix more build breaks

* Fix more build errors

* Fix more build breaks

* Runtime fixes 1

* Get connection dialog working with some todos

* Fix a few packaging issues

* Copy several node_modules to package build to fix loader issues

* Fix breaks from master

* A few more fixes

* Make tests pass

* First pass of license header updates

* Second pass of license header updates

* Fix restore dialog issues

* Remove add additional themes menu items

* fix select box issues where the list doesn't show up

* formatting

* Fix editor dispose issue

* Copy over node modules to correct location on all platforms
This commit is contained in:
Karl Burtram
2018-04-04 15:27:51 -07:00
committed by GitHub
parent 5fba3e31b4
commit dafb780987
9412 changed files with 141255 additions and 98813 deletions

View File

@@ -27,8 +27,7 @@
}
.monaco-editor .reference-zone-widget .ref-tree {
line-height: 22px;
font-size: 13px;
line-height: 23px;
}
.monaco-editor .reference-zone-widget .ref-tree .reference {

View File

@@ -134,6 +134,7 @@ export abstract class PeekViewWidget extends ZoneWidget {
const actionsContainer = $('.peekview-actions').appendTo(this._headElement);
const actionBarOptions = this._getActionBarOptions();
this._actionbarWidget = new ActionBar(actionsContainer, actionBarOptions);
this._disposables.push(this._actionbarWidget);
this._actionbarWidget.push(new Action('peekview.close', nls.localize('label.close', "Close"), 'close-peekview-action', true, () => {
this.dispose();

View File

@@ -19,12 +19,15 @@ import { registerEditorAction, ServicesAccessor, EditorAction, registerEditorCon
import { Location, ReferenceProviderRegistry } from 'vs/editor/common/modes';
import { PeekContext, getOuterEditor } from './peekViewWidget';
import { ReferencesController, RequestOptions, ctxReferenceSearchVisible } from './referencesController';
import { ReferencesModel } from './referencesModel';
import { ReferencesModel, OneReference } from './referencesModel';
import { asWinJsPromise } from 'vs/base/common/async';
import { onUnexpectedExternalError } from 'vs/base/common/errors';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { ICodeEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { ITextModel } from 'vs/editor/common/model';
import { IListService } from 'vs/platform/list/browser/listService';
import { ctxReferenceWidgetSearchTreeFocused } from 'vs/editor/contrib/referenceSearch/referencesWidget';
const defaultReferenceSearchOptions: RequestOptions = {
getMetaTitle(model) {
@@ -165,6 +168,19 @@ CommandsRegistry.registerCommand({
});
function closeActiveReferenceSearch(accessor: ServicesAccessor, args: any) {
withController(accessor, controller => controller.closeWidget());
}
function openReferenceToSide(accessor: ServicesAccessor, args: any) {
const listService = accessor.get(IListService);
const focus = listService.lastFocusedList && listService.lastFocusedList.getFocus();
if (focus instanceof OneReference) {
withController(accessor, controller => controller.openReference(focus, true));
}
}
function withController(accessor: ServicesAccessor, fn: (controller: ReferencesController) => void): void {
var outerEditor = getOuterEditor(accessor);
if (!outerEditor) {
return;
@@ -175,12 +191,12 @@ function closeActiveReferenceSearch(accessor: ServicesAccessor, args: any) {
return;
}
controller.closeWidget();
fn(controller);
}
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'closeReferenceSearch',
weight: KeybindingsRegistry.WEIGHT.editorContrib(50),
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50),
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape],
when: ContextKeyExpr.and(ctxReferenceSearchVisible, ContextKeyExpr.not('config.editor.stablePeek')),
@@ -196,8 +212,18 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: closeActiveReferenceSearch
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'openReferenceToSide',
weight: KeybindingsRegistry.WEIGHT.editorContrib(),
primary: KeyMod.CtrlCmd | KeyCode.Enter,
mac: {
primary: KeyMod.WinCtrl | KeyCode.Enter
},
when: ContextKeyExpr.and(ctxReferenceSearchVisible, ctxReferenceWidgetSearchTreeFocused),
handler: openReferenceToSide
});
export function provideReferences(model: editorCommon.IReadOnlyModel, position: Position): TPromise<Location[]> {
export function provideReferences(model: ITextModel, position: Position): TPromise<Location[]> {
// collect references from all providers
const promises = ReferenceProviderRegistry.ordered(model).map(provider => {

View File

@@ -7,31 +7,31 @@
import * as nls from 'vs/nls';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import Severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
import { IEditorService } from 'vs/platform/editor/common/editor';
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IMessageService } from 'vs/platform/message/common/message';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IStorageService } from 'vs/platform/storage/common/storage';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { ReferencesModel, OneReference } from './referencesModel';
import { ReferencesModel } from './referencesModel';
import { ReferenceWidget, LayoutData } from './referencesWidget';
import { Range } from 'vs/editor/common/core/range';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Position } from 'vs/editor/common/core/position';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { Location } from 'vs/editor/common/modes';
import { INotificationService } from 'vs/platform/notification/common/notification';
export const ctxReferenceSearchVisible = new RawContextKey<boolean>('referenceSearchVisible', false);
export interface RequestOptions {
getMetaTitle(model: ReferencesModel): string;
onGoto?: (reference: OneReference) => TPromise<any>;
onGoto?: (reference: Location) => TPromise<any>;
}
export class ReferencesController implements editorCommon.IEditorContribution {
@@ -54,14 +54,14 @@ export class ReferencesController implements editorCommon.IEditorContribution {
public constructor(
editor: ICodeEditor,
@IContextKeyService contextKeyService: IContextKeyService,
@IEditorService private _editorService: IEditorService,
@ITextModelService private _textModelResolverService: ITextModelService,
@IMessageService private _messageService: IMessageService,
@IInstantiationService private _instantiationService: IInstantiationService,
@IWorkspaceContextService private _contextService: IWorkspaceContextService,
@IStorageService private _storageService: IStorageService,
@IThemeService private _themeService: IThemeService,
@IConfigurationService private _configurationService: IConfigurationService,
@IEditorService private readonly _editorService: IEditorService,
@ITextModelService private readonly _textModelResolverService: ITextModelService,
@INotificationService private readonly _notificationService: INotificationService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
@IStorageService private readonly _storageService: IStorageService,
@IThemeService private readonly _themeService: IThemeService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@optional(IEnvironmentService) private _environmentService: IEnvironmentService
) {
this._editor = editor;
@@ -126,7 +126,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
break;
}
case 'side':
this._openReference(element, kind === 'side');
this.openReference(element, kind === 'side');
break;
case 'goto':
if (options.onGoto) {
@@ -170,7 +170,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
});
}, error => {
this._messageService.show(Severity.Error, error);
this._notificationService.error(error);
});
}
@@ -189,7 +189,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
this._requestIdPool += 1; // Cancel pending requests
}
private _gotoReference(ref: OneReference): void {
private _gotoReference(ref: Location): void {
this._widget.hide();
this._ignoreModelChangeEvent = true;
@@ -222,7 +222,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
});
}
private _openReference(ref: OneReference, sideBySide: boolean): void {
public openReference(ref: Location, sideBySide: boolean): void {
const { uri, range } = ref;
this._editorService.openEditor({
resource: uri,

View File

@@ -23,13 +23,11 @@ import { GestureEvent } from 'vs/base/browser/touch';
import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
import { FileLabel } from 'vs/base/browser/ui/iconLabel/iconLabel';
import * as tree from 'vs/base/parts/tree/browser/tree';
import { DefaultController } from 'vs/base/parts/tree/browser/treeDefaults';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { Range, IRange } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { Model } from 'vs/editor/common/model/model';
import { TextModel, ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { PeekViewWidget } from './peekViewWidget';
@@ -40,13 +38,17 @@ import { registerThemingParticipant, ITheme, IThemeService } from 'vs/platform/t
import { attachListStyler, attachBadgeStyler } from 'vs/platform/theme/common/styler';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
import URI from 'vs/base/common/uri';
import { TrackedRangeStickiness, IModelDeltaDecoration } from 'vs/editor/common/model';
import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Location } from 'vs/editor/common/modes';
import { ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
class DecorationsManager implements IDisposable {
private static readonly DecorationOptions = ModelDecorationOptions.register({
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className: 'reference-decoration'
});
@@ -84,7 +86,7 @@ class DecorationsManager implements IDisposable {
this._editor.changeDecorations(accessor => {
const newDecorations: editorCommon.IModelDeltaDecoration[] = [];
const newDecorations: IModelDeltaDecoration[] = [];
const newDecorationsActualIndex: number[] = [];
for (let i = 0, len = reference.children.length; i < len; i++) {
@@ -162,7 +164,7 @@ class DecorationsManager implements IDisposable {
class DataSource implements tree.IDataSource {
constructor(
@ITextModelService private _textModelResolverService: ITextModelService
@ITextModelService private readonly _textModelResolverService: ITextModelService
) {
//
}
@@ -216,7 +218,7 @@ class DataSource implements tree.IDataSource {
}
}
class Controller extends DefaultController {
class Controller extends WorkbenchTreeController {
private _onDidFocus = new Emitter<any>();
readonly onDidFocus: Event<any> = this._onDidFocus.event;
@@ -241,19 +243,23 @@ class Controller extends DefaultController {
}
public onMouseDown(tree: tree.ITree, element: any, event: IMouseEvent): boolean {
var isDoubleClick = event.detail === 2;
if (event.leftButton) {
if (element instanceof FileReferences) {
event.preventDefault();
event.stopPropagation();
return this._expandCollapse(tree, element);
if (this.openOnSingleClick || isDoubleClick || this.isClickOnTwistie(event)) {
event.preventDefault();
event.stopPropagation();
return this._expandCollapse(tree, element);
}
}
var result = super.onClick(tree, element, event);
if (event.ctrlKey || event.metaKey) {
var openToSide = event.ctrlKey || event.metaKey || event.altKey;
if (openToSide && (isDoubleClick || this.openOnSingleClick)) {
this._onDidOpenToSide.fire(element);
} else if (event.detail === 2) {
} else if (isDoubleClick) {
this._onDidSelect.fire(element);
} else {
} else if (this.openOnSingleClick) {
this._onDidFocus.fire(element);
}
return result;
@@ -284,65 +290,6 @@ class Controller extends DefaultController {
return false;
}
public onEnter(tree: tree.ITree, event: IKeyboardEvent): boolean {
var element = tree.getFocus();
if (element instanceof FileReferences) {
return this._expandCollapse(tree, element);
}
var result = super.onEnter(tree, event);
if (event.ctrlKey || event.metaKey) {
this._onDidOpenToSide.fire(element);
} else {
this._onDidSelect.fire(element);
}
return result;
}
public onUp(tree: tree.ITree, event: IKeyboardEvent): boolean {
super.onUp(tree, event);
this._fakeFocus(tree, event);
return true;
}
public onPageUp(tree: tree.ITree, event: IKeyboardEvent): boolean {
super.onPageUp(tree, event);
this._fakeFocus(tree, event);
return true;
}
public onLeft(tree: tree.ITree, event: IKeyboardEvent): boolean {
super.onLeft(tree, event);
this._fakeFocus(tree, event);
return true;
}
public onDown(tree: tree.ITree, event: IKeyboardEvent): boolean {
super.onDown(tree, event);
this._fakeFocus(tree, event);
return true;
}
public onPageDown(tree: tree.ITree, event: IKeyboardEvent): boolean {
super.onPageDown(tree, event);
this._fakeFocus(tree, event);
return true;
}
public onRight(tree: tree.ITree, event: IKeyboardEvent): boolean {
super.onRight(tree, event);
this._fakeFocus(tree, event);
return true;
}
private _fakeFocus(tree: tree.ITree, event: IKeyboardEvent): void {
// focus next item
var focus = tree.getFocus();
tree.setSelection([focus]);
// send out event
this._onDidFocus.fire(focus);
}
dispose(): void {
this._onDidFocus.dispose();
this._onDidSelect.dispose();
@@ -358,7 +305,7 @@ class FileReferencesTemplate {
constructor(
container: HTMLElement,
@IWorkspaceContextService private _contextService: IWorkspaceContextService,
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
@optional(IEnvironmentService) private _environmentService: IEnvironmentService,
@IThemeService themeService: IThemeService,
) {
@@ -425,15 +372,15 @@ class Renderer implements tree.IRenderer {
};
constructor(
@IWorkspaceContextService private _contextService: IWorkspaceContextService,
@IThemeService private _themeService: IThemeService,
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
@IThemeService private readonly _themeService: IThemeService,
@optional(IEnvironmentService) private _environmentService: IEnvironmentService,
) {
//
}
getHeight(tree: tree.ITree, element: FileReferences | OneReference): number {
return 22;
return 23;
}
getTemplateId(tree: tree.ITree, element: FileReferences | OneReference): string {
@@ -558,9 +505,11 @@ export interface LayoutData {
export interface SelectionEvent {
kind: 'goto' | 'show' | 'side' | 'open';
source: 'editor' | 'tree' | 'title';
element: OneReference;
element: Location;
}
export const ctxReferenceWidgetSearchTreeFocused = new RawContextKey<boolean>('referenceSearchTreeFocused', true);
/**
* ZoneWidget that is shown inside the editor
*/
@@ -573,12 +522,12 @@ export class ReferenceWidget extends PeekViewWidget {
private _callOnDispose: IDisposable[] = [];
private _onDidSelectReference = new Emitter<SelectionEvent>();
private _tree: Tree;
private _tree: WorkbenchTree;
private _treeContainer: Builder;
private _sash: VSash;
private _preview: ICodeEditor;
private _previewModelReference: IReference<ITextEditorModel>;
private _previewNotAvailableMessage: Model;
private _previewNotAvailableMessage: TextModel;
private _previewContainer: Builder;
private _messageContainer: Builder;
@@ -633,7 +582,7 @@ export class ReferenceWidget extends PeekViewWidget {
if (this._preview && this._preview.getModel()) {
this._onDidSelectReference.fire({
element: this._getFocusedReference(),
kind: e.ctrlKey || e.metaKey ? 'side' : 'open',
kind: e.ctrlKey || e.metaKey || e.altKey ? 'side' : 'open',
source: 'title'
});
}
@@ -670,7 +619,7 @@ export class ReferenceWidget extends PeekViewWidget {
this._preview = this._instantiationService.createInstance(EmbeddedCodeEditorWidget, div.getHTMLElement(), options, this.editor);
this._previewContainer = div.hide();
this._previewNotAvailableMessage = Model.createFromString(nls.localize('missingPreviewMessage', "no preview available"));
this._previewNotAvailableMessage = TextModel.createFromString(nls.localize('missingPreviewMessage', "no preview available"));
});
// sash
@@ -686,7 +635,9 @@ export class ReferenceWidget extends PeekViewWidget {
// tree
container.div({ 'class': 'ref-tree inline' }, (div: Builder) => {
const controller = new Controller();
var controller = this._instantiationService.createInstance(Controller, { clickBehavior: ClickBehavior.ON_MOUSE_UP /* our controller already deals with this */ });
this._callOnDispose.push(controller);
var config = <tree.ITreeConfiguration>{
dataSource: this._instantiationService.createInstance(DataSource),
renderer: this._instantiationService.createInstance(Renderer),
@@ -694,33 +645,39 @@ export class ReferenceWidget extends PeekViewWidget {
accessibilityProvider: new AriaProvider()
};
// listen on selection and focus
this._disposables.push(controller.onDidFocus((element) => {
if (element instanceof OneReference) {
this._revealReference(element);
this._onDidSelectReference.fire({ element, kind: 'show', source: 'tree' });
}
}));
this._disposables.push(controller.onDidSelect((element: any) => {
if (element instanceof OneReference) {
this._onDidSelectReference.fire({ element, kind: 'goto', source: 'tree' });
}
}));
this._disposables.push(controller.onDidOpenToSide((element: any) => {
if (element instanceof OneReference) {
this._onDidSelectReference.fire({ element, kind: 'side', source: 'tree' });
}
}));
var options = {
allowHorizontalScroll: false,
var options: tree.ITreeOptions = {
twistiePixels: 20,
ariaLabel: nls.localize('treeAriaLabel', "References")
};
this._tree = new Tree(div.getHTMLElement(), config, options);
this._tree = this._instantiationService.createInstance(WorkbenchTree, div.getHTMLElement(), config, options);
this._callOnDispose.push(attachListStyler(this._tree, this._themeService));
ctxReferenceWidgetSearchTreeFocused.bindTo(this._tree.contextKeyService);
// listen on selection and focus
var onEvent = (element: any, kind: 'show' | 'goto' | 'side') => {
if (element instanceof OneReference) {
if (kind === 'show') {
this._revealReference(element);
}
this._onDidSelectReference.fire({ element, kind, source: 'tree' });
}
};
this._disposables.push(this._tree.onDidChangeFocus(event => {
if (event && event.payload && event.payload.origin === 'keyboard') {
onEvent(event.focus, 'show'); // only handle events from keyboard, mouse/touch is handled by other listeners below
}
}));
this._disposables.push(this._tree.onDidChangeSelection(event => {
if (event && event.payload && event.payload.origin === 'keyboard') {
onEvent(event.selection[0], 'goto'); // only handle events from keyboard, mouse/touch is handled by other listeners below
}
}));
this._disposables.push(controller.onDidFocus(element => onEvent(element, 'show')));
this._disposables.push(controller.onDidSelect(element => onEvent(element, 'goto')));
this._disposables.push(controller.onDidOpenToSide(element => onEvent(element, 'side')));
this._treeContainer = div.hide();
});
}
@@ -754,7 +711,12 @@ export class ReferenceWidget extends PeekViewWidget {
}
public setSelection(selection: OneReference): TPromise<any> {
return this._revealReference(selection);
return this._revealReference(selection).then(() => {
// show in tree
this._tree.setSelection([selection]);
this._tree.setFocus(selection);
});
}
public setModel(newModel: ReferencesModel): TPromise<any> {
@@ -783,11 +745,12 @@ export class ReferenceWidget extends PeekViewWidget {
this._disposeOnNewModel.push(this._model.onDidChangeReferenceRange(reference => this._tree.refresh(reference)));
// listen on editor
this._disposeOnNewModel.push(this._preview.onMouseDown((e) => {
if (e.event.detail === 2) {
this._disposeOnNewModel.push(this._preview.onMouseDown(e => {
const { event, target } = e;
if (event.detail === 2) {
this._onDidSelectReference.fire({
element: this._getFocusedReference(),
kind: (e.event.ctrlKey || e.event.metaKey) ? 'side' : 'open',
element: { uri: this._getFocusedReference().uri, range: target.range },
kind: (event.ctrlKey || event.metaKey || event.altKey) ? 'side' : 'open',
source: 'editor'
});
}
@@ -818,7 +781,7 @@ export class ReferenceWidget extends PeekViewWidget {
return undefined;
}
private _revealReference(reference: OneReference) {
private _revealReference(reference: OneReference): TPromise<void> {
// Update widget header
if (reference.uri.scheme !== Schemas.inMemory) {
@@ -853,11 +816,6 @@ export class ReferenceWidget extends PeekViewWidget {
this._preview.setModel(this._previewNotAvailableMessage);
ref.dispose();
}
// show in tree
this._tree.setSelection([reference]);
this._tree.setFocus(reference);
}, onUnexpectedError);
}
}