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

@@ -32,6 +32,7 @@ import { editorErrorForeground, editorErrorBorder, editorWarningForeground, edit
import { Color } from 'vs/base/common/color';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import { ClassName } from 'vs/editor/common/model/intervalTree';
import { ITextModel, IModelDecorationOptions } from 'vs/editor/common/model';
export abstract class CodeEditorWidget extends CommonCodeEditor implements editorBrowser.ICodeEditor {
@@ -157,8 +158,8 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
super.dispose();
}
public createOverviewRuler(cssClassName: string, minimumHeight: number, maximumHeight: number): editorBrowser.IOverviewRuler {
return this._view.createOverviewRuler(cssClassName, minimumHeight, maximumHeight);
public createOverviewRuler(cssClassName: string): editorBrowser.IOverviewRuler {
return this._view.createOverviewRuler(cssClassName);
}
public getDomNode(): HTMLElement {
@@ -326,7 +327,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
Configuration.applyFontInfoSlow(target, this._configuration.editor.fontInfo);
}
_attachModel(model: editorCommon.IModel): void {
_attachModel(model: ITextModel): void {
this._view = null;
super._attachModel(model);
@@ -392,7 +393,17 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
viewEventBus.onKeyDown = (e) => this._onKeyDown.fire(e);
}
protected _detachModel(): editorCommon.IModel {
public restoreViewState(s: editorCommon.ICodeEditorViewState): void {
super.restoreViewState(s);
if (!this.cursor || !this.hasView) {
return;
}
if (s && s.cursorState && s.viewState) {
this._view.restoreState(this.viewModel.viewLayout.reduceRestoreState(s.viewState));
}
}
protected _detachModel(): ITextModel {
let removeDomNode: HTMLElement = null;
if (this._view) {
@@ -420,7 +431,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
this._codeEditorService.removeDecorationType(key);
}
protected _resolveDecorationOptions(typeKey: string, writable: boolean): editorCommon.IModelDecorationOptions {
protected _resolveDecorationOptions(typeKey: string, writable: boolean): IModelDecorationOptions {
return this._codeEditorService.resolveDecorationOptions(typeKey, writable);
}

View File

@@ -11,7 +11,6 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import { Disposable } from 'vs/base/common/lifecycle';
import * as objects from 'vs/base/common/objects';
import * as dom from 'vs/base/browser/dom';
import Severity from 'vs/base/common/severity';
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
import { ISashEvent, IVerticalSashLayoutProvider, Sash } from 'vs/base/browser/ui/sash/sash';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -24,7 +23,7 @@ import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
import { renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
import { CodeEditor } from 'vs/editor/browser/codeEditor';
import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { LineTokens } from 'vs/editor/common/core/lineTokens';
import { Configuration } from 'vs/editor/browser/config/configuration';
import { Position, IPosition } from 'vs/editor/common/core/position';
import { Selection, ISelection } from 'vs/editor/common/core/selection';
@@ -38,14 +37,15 @@ import { scrollbarShadow, diffInserted, diffRemoved, defaultInsertColor, default
import { Color } from 'vs/base/common/color';
import { OverviewRulerZone } from 'vs/editor/common/view/overviewZoneManager';
import { IEditorWhitespace } from 'vs/editor/common/viewLayout/whitespaceComputer';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { DiffReview } from 'vs/editor/browser/widget/diffReview';
import URI from 'vs/base/common/uri';
import { IMessageService } from 'vs/platform/message/common/message';
import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder';
import { IModelDeltaDecoration, IModelDecorationsChangeAccessor, ITextModel } from 'vs/editor/common/model';
import { INotificationService } from 'vs/platform/notification/common/notification';
interface IEditorDiffDecorations {
decorations: editorCommon.IModelDeltaDecoration[];
decorations: IModelDeltaDecoration[];
overviewZones: OverviewRulerZone[];
}
@@ -100,7 +100,7 @@ class VisualEditorState {
// (2) Model decorations
if (this._decorations.length > 0) {
editor.changeDecorations((changeAccessor: editorCommon.IModelDecorationsChangeAccessor) => {
editor.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => {
changeAccessor.deltaDecorations(this._decorations, []);
});
}
@@ -191,7 +191,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
protected _contextKeyService: IContextKeyService;
private _codeEditorService: ICodeEditorService;
private _themeService: IThemeService;
private readonly _messageService: IMessageService;
private _notificationService: INotificationService;
private _reviewPane: DiffReview;
@@ -203,16 +203,16 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
@IInstantiationService instantiationService: IInstantiationService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@IThemeService themeService: IThemeService,
@IMessageService messageService: IMessageService
@INotificationService notificationService: INotificationService
) {
super();
this._editorWorkerService = editorWorkerService;
this._codeEditorService = codeEditorService;
this._contextKeyService = contextKeyService.createScoped(domElement);
this._contextKeyService = this._register(contextKeyService.createScoped(domElement));
this._contextKeyService.createKey('isInDiffEditor', true);
this._themeService = themeService;
this._messageService = messageService;
this._notificationService = notificationService;
this.id = (++DIFF_EDITOR_ID);
@@ -313,14 +313,14 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._setStrategy(new DiffEdtorWidgetInline(this._createDataSource(), this._enableSplitViewResizing));
}
this._codeEditorService.addDiffEditor(this);
this._register(themeService.onThemeChange(t => {
if (this._strategy && this._strategy.applyColors(t)) {
this._updateDecorationsRunner.schedule();
}
this._containerDomElement.className = DiffEditorWidget._getClassName(this._themeService.getTheme(), this._renderSideBySide);
}));
this._codeEditorService.addDiffEditor(this);
}
public get ignoreTrimWhitespace(): boolean {
@@ -361,14 +361,14 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._overviewDomElement.removeChild(this._originalOverviewRuler.getDomNode());
this._originalOverviewRuler.dispose();
}
this._originalOverviewRuler = this.originalEditor.createOverviewRuler('original diffOverviewRuler', 4, Number.MAX_VALUE);
this._originalOverviewRuler = this.originalEditor.createOverviewRuler('original diffOverviewRuler');
this._overviewDomElement.appendChild(this._originalOverviewRuler.getDomNode());
if (this._modifiedOverviewRuler) {
this._overviewDomElement.removeChild(this._modifiedOverviewRuler.getDomNode());
this._modifiedOverviewRuler.dispose();
}
this._modifiedOverviewRuler = this.modifiedEditor.createOverviewRuler('modified diffOverviewRuler', 4, Number.MAX_VALUE);
this._modifiedOverviewRuler = this.modifiedEditor.createOverviewRuler('modified diffOverviewRuler');
this._overviewDomElement.appendChild(this._modifiedOverviewRuler.getDomNode());
this._layoutOverviewRulers();
@@ -465,20 +465,37 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
public dispose(): void {
this._codeEditorService.removeDiffEditor(this);
if (this._beginUpdateDecorationsTimeout !== -1) {
window.clearTimeout(this._beginUpdateDecorationsTimeout);
this._beginUpdateDecorationsTimeout = -1;
}
window.clearInterval(this._measureDomElementToken);
this._cleanViewZonesAndDecorations();
this._overviewDomElement.removeChild(this._originalOverviewRuler.getDomNode());
this._originalOverviewRuler.dispose();
this._overviewDomElement.removeChild(this._modifiedOverviewRuler.getDomNode());
this._modifiedOverviewRuler.dispose();
this._overviewDomElement.removeChild(this._overviewViewportDomElement.domNode);
this._containerDomElement.removeChild(this._overviewDomElement);
this._containerDomElement.removeChild(this._originalDomNode);
this.originalEditor.dispose();
this._containerDomElement.removeChild(this._modifiedDomNode);
this.modifiedEditor.dispose();
this._strategy.dispose();
this._containerDomElement.removeChild(this._reviewPane.domNode.domNode);
this._containerDomElement.removeChild(this._reviewPane.shadow.domNode);
this._containerDomElement.removeChild(this._reviewPane.actionBarContainer.domNode);
this._reviewPane.dispose();
this._domElement.removeChild(this._containerDomElement);
this._onDidDispose.fire();
super.dispose();
@@ -746,7 +763,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this.modifiedEditor.trigger(source, handlerId, payload);
}
public changeDecorations(callback: (changeAccessor: editorCommon.IModelDecorationsChangeAccessor) => any): any {
public changeDecorations(callback: (changeAccessor: IModelDecorationsChangeAccessor) => any): any {
return this.modifiedEditor.changeDecorations(callback);
}
@@ -852,7 +869,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
) {
this._lastOriginalWarning = currentOriginalModel.uri;
this._lastModifiedWarning = currentModifiedModel.uri;
this._messageService.show(Severity.Warning, nls.localize("diff.tooLarge", "Cannot compare files because one file is too large."));
this._notificationService.warn(nls.localize("diff.tooLarge", "Cannot compare files because one file is too large."));
}
return;
}
@@ -1594,6 +1611,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
}
_getOriginalEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
const overviewZoneColor = this._removeColor.toString();
let result: IEditorDiffDecorations = {
decorations: [],
@@ -1614,16 +1632,10 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
result.decorations.push(createDecoration(lineChange.originalStartLineNumber, 1, lineChange.originalEndLineNumber, Number.MAX_VALUE, DECORATIONS.charDeleteWholeLine));
}
let color = this._removeColor.toString();
result.overviewZones.push(new OverviewRulerZone(
lineChange.originalStartLineNumber,
lineChange.originalEndLineNumber,
editorCommon.OverviewRulerLane.Full,
0,
color,
color,
color
overviewZoneColor
));
if (lineChange.charChanges) {
@@ -1659,6 +1671,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
}
_getModifiedEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
const overviewZoneColor = this._insertColor.toString();
let result: IEditorDiffDecorations = {
decorations: [],
@@ -1679,15 +1692,10 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
if (!isChangeOrDelete(lineChange) || !lineChange.charChanges) {
result.decorations.push(createDecoration(lineChange.modifiedStartLineNumber, 1, lineChange.modifiedEndLineNumber, Number.MAX_VALUE, DECORATIONS.charInsertWholeLine));
}
let color = this._insertColor.toString();
result.overviewZones.push(new OverviewRulerZone(
lineChange.modifiedStartLineNumber,
lineChange.modifiedEndLineNumber,
editorCommon.OverviewRulerLane.Full,
0,
color,
color,
color
overviewZoneColor
));
if (lineChange.charChanges) {
@@ -1783,6 +1791,8 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
}
_getOriginalEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
const overviewZoneColor = this._removeColor.toString();
let result: IEditorDiffDecorations = {
decorations: [],
overviewZones: []
@@ -1798,15 +1808,10 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
options: DECORATIONS.lineDeleteMargin
});
let color = this._removeColor.toString();
result.overviewZones.push(new OverviewRulerZone(
lineChange.originalStartLineNumber,
lineChange.originalEndLineNumber,
editorCommon.OverviewRulerLane.Full,
0,
color,
color,
color
overviewZoneColor
));
}
}
@@ -1815,6 +1820,7 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
}
_getModifiedEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
const overviewZoneColor = this._insertColor.toString();
let result: IEditorDiffDecorations = {
decorations: [],
@@ -1833,15 +1839,10 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
options: (renderIndicators ? DECORATIONS.lineInsertWithSign : DECORATIONS.lineInsert)
});
let color = this._insertColor.toString();
result.overviewZones.push(new OverviewRulerZone(
lineChange.modifiedStartLineNumber,
lineChange.modifiedEndLineNumber,
editorCommon.OverviewRulerLane.Full,
0,
color,
color,
color
overviewZoneColor
));
if (lineChange.charChanges) {
@@ -1887,7 +1888,7 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
class InlineViewZonesComputer extends ViewZonesComputer {
private originalModel: editorCommon.IModel;
private originalModel: ITextModel;
private modifiedEditorConfiguration: editorOptions.InternalEditorOptions;
private modifiedEditorTabSize: number;
private renderIndicators: boolean;
@@ -1962,7 +1963,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
};
}
private renderOriginalLine(count: number, originalModel: editorCommon.IModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): void {
private renderOriginalLine(count: number, originalModel: ITextModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): void {
let lineContent = originalModel.getLineContent(lineNumber);
let actualDecorations = LineDecoration.filter(decorations, lineNumber, 1, lineContent.length + 1);
@@ -1973,6 +1974,12 @@ class InlineViewZonesComputer extends ViewZonesComputer {
| (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)
) >>> 0;
const tokens = new Uint32Array(2);
tokens[0] = lineContent.length;
tokens[1] = defaultMetadata;
const lineTokens = new LineTokens(tokens, lineContent);
sb.appendASCIIString('<div class="view-line');
if (decorations.length === 0) {
// No char changes
@@ -1987,7 +1994,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
lineContent,
originalModel.mightContainRTL(),
0,
[new ViewLineToken(lineContent.length, defaultMetadata)],
lineTokens,
actualDecorations,
tabSize,
config.fontInfo.spaceWidth,

View File

@@ -25,7 +25,7 @@ export interface Options {
alwaysRevealFirst?: boolean;
}
var defaultOptions: Options = {
const defaultOptions: Options = {
followsCaret: true,
ignoreCharChanges: true,
alwaysRevealFirst: true
@@ -84,7 +84,7 @@ export class DiffNavigator {
}
private _init(): void {
var changes = this._editor.getLineChanges();
let changes = this._editor.getLineChanges();
if (!changes) {
return;
}
@@ -149,10 +149,10 @@ export class DiffNavigator {
}
private _initIdx(fwd: boolean): void {
var found = false;
var position = this._editor.getPosition();
for (var i = 0, len = this.ranges.length; i < len && !found; i++) {
var range = this.ranges[i].range;
let found = false;
let position = this._editor.getPosition();
for (let i = 0, len = this.ranges.length; i < len && !found; i++) {
let range = this.ranges[i].range;
if (position.isBeforeOrEqual(range.getStartPosition())) {
this.nextIdx = i + (fwd ? 0 : -1);
found = true;
@@ -189,10 +189,10 @@ export class DiffNavigator {
}
}
var info = this.ranges[this.nextIdx];
let info = this.ranges[this.nextIdx];
this.ignoreSelectionChange = true;
try {
var pos = info.range.getStartPosition();
let pos = info.range.getStartPosition();
this._editor.setPosition(pos);
this._editor.revealPositionInCenter(pos, ScrollType.Smooth);
} finally {

View File

@@ -11,7 +11,7 @@ import * as dom from 'vs/base/browser/dom';
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { renderViewLine2 as renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { LineTokens } from 'vs/editor/common/core/lineTokens';
import { Configuration } from 'vs/editor/browser/config/configuration';
import { Position } from 'vs/editor/common/core/position';
import { ColorId, MetadataConsts, FontStyle } from 'vs/editor/common/modes';
@@ -28,6 +28,7 @@ import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model';
const DIFF_LINES_PADDING = 3;
@@ -607,8 +608,8 @@ export class DiffReview extends Disposable {
private static _renderSection(
dest: HTMLElement, diffEntry: DiffEntry, modLine: number, width: number,
originalOpts: editorOptions.InternalEditorOptions, originalModel: editorCommon.IModel, originalModelOpts: editorCommon.TextModelResolvedOptions,
modifiedOpts: editorOptions.InternalEditorOptions, modifiedModel: editorCommon.IModel, modifiedModelOpts: editorCommon.TextModelResolvedOptions
originalOpts: editorOptions.InternalEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions,
modifiedOpts: editorOptions.InternalEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions
): void {
const type = diffEntry.getType();
@@ -722,7 +723,7 @@ export class DiffReview extends Disposable {
}
}
private static _renderLine(model: editorCommon.IModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number): string {
private static _renderLine(model: ITextModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number): string {
const lineContent = model.getLineContent(lineNumber);
const defaultMetadata = (
@@ -731,12 +732,18 @@ export class DiffReview extends Disposable {
| (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)
) >>> 0;
const tokens = new Uint32Array(2);
tokens[0] = lineContent.length;
tokens[1] = defaultMetadata;
const lineTokens = new LineTokens(tokens, lineContent);
const r = renderViewLine(new RenderLineInput(
(config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations),
lineContent,
model.mightContainRTL(),
0,
[new ViewLineToken(lineContent.length, defaultMetadata)],
lineTokens,
[],
tabSize,
config.fontInfo.spaceWidth,

View File

@@ -15,7 +15,7 @@ import { IConfigurationChangedEvent, IEditorOptions, IDiffEditorOptions } from '
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { IMessageService } from 'vs/platform/message/common/message';
import { INotificationService } from 'vs/platform/notification/common/notification';
export class EmbeddedCodeEditorWidget extends CodeEditor {
@@ -72,9 +72,9 @@ export class EmbeddedDiffEditorWidget extends DiffEditorWidget {
@IInstantiationService instantiationService: IInstantiationService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@IThemeService themeService: IThemeService,
@IMessageService messageService: IMessageService
@INotificationService notificationService: INotificationService
) {
super(domElement, parentEditor.getRawConfiguration(), editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, messageService);
super(domElement, parentEditor.getRawConfiguration(), editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService);
this._parentEditor = parentEditor;
this._overwriteOptions = options;