mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 18:48:33 -05:00
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:
@@ -5,16 +5,16 @@
|
||||
'use strict';
|
||||
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { PrefixSumComputerWithCache } from 'vs/editor/common/viewModel/prefixSumComputer';
|
||||
import { ViewLineData, ICoordinatesConverter, IOverviewRulerDecorations } from 'vs/editor/common/viewModel/viewModel';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
|
||||
import { ModelDecorationOptions, ModelDecorationOverviewRulerOptions } from 'vs/editor/common/model/textModelWithDecorations';
|
||||
import { ModelDecorationOptions, ModelDecorationOverviewRulerOptions } from 'vs/editor/common/model/textModel';
|
||||
import { ThemeColor, ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { IModelDecoration, ITextModel, IModelDeltaDecoration, EndOfLinePreference } from 'vs/editor/common/model';
|
||||
|
||||
export class OutputPosition {
|
||||
_outputPositionBrand: void;
|
||||
@@ -38,11 +38,12 @@ export interface ILineMapperFactory {
|
||||
createLineMapping(lineText: string, tabSize: number, wrappingColumn: number, columnsForFullWidthChar: number, wrappingIndent: WrappingIndent): ILineMapping;
|
||||
}
|
||||
|
||||
export interface IModel {
|
||||
export interface ISimpleModel {
|
||||
getLineTokens(lineNumber: number): LineTokens;
|
||||
getLineContent(lineNumber: number): string;
|
||||
getLineMinColumn(lineNumber: number): number;
|
||||
getLineMaxColumn(lineNumber: number): number;
|
||||
getValueInRange(range: IRange, eol?: EndOfLinePreference): string;
|
||||
}
|
||||
|
||||
export interface ISplitLine {
|
||||
@@ -50,11 +51,11 @@ export interface ISplitLine {
|
||||
setVisible(isVisible: boolean): ISplitLine;
|
||||
|
||||
getViewLineCount(): number;
|
||||
getViewLineContent(model: IModel, modelLineNumber: number, outputLineIndex: number): string;
|
||||
getViewLineMinColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number;
|
||||
getViewLineMaxColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number;
|
||||
getViewLineData(model: IModel, modelLineNumber: number, outputLineIndex: number): ViewLineData;
|
||||
getViewLinesData(model: IModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void;
|
||||
getViewLineContent(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): string;
|
||||
getViewLineMinColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number;
|
||||
getViewLineMaxColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number;
|
||||
getViewLineData(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): ViewLineData;
|
||||
getViewLinesData(model: ISimpleModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void;
|
||||
|
||||
getModelColumnOfViewPosition(outputLineIndex: number, outputColumn: number): number;
|
||||
getViewPositionOfModelPosition(deltaLineNumber: number, inputColumn: number): Position;
|
||||
@@ -68,6 +69,7 @@ export interface IViewModelLinesCollection {
|
||||
|
||||
setWrappingSettings(wrappingIndent: WrappingIndent, wrappingColumn: number, columnsForFullWidthChar: number): boolean;
|
||||
setTabSize(newTabSize: number): boolean;
|
||||
getHiddenAreas(): Range[];
|
||||
setHiddenAreas(_ranges: Range[]): boolean;
|
||||
|
||||
onModelFlushed(): void;
|
||||
@@ -86,7 +88,7 @@ export interface IViewModelLinesCollection {
|
||||
getViewLinesData(viewStartLineNumber: number, viewEndLineNumber: number, needed: boolean[]): ViewLineData[];
|
||||
|
||||
getAllOverviewRulerDecorations(ownerId: number, filterOutValidation: boolean, theme: ITheme): IOverviewRulerDecorations;
|
||||
getDecorationsInRange(range: Range, ownerId: number, filterOutValidation: boolean): editorCommon.IModelDecoration[];
|
||||
getDecorationsInRange(range: Range, ownerId: number, filterOutValidation: boolean): IModelDecoration[];
|
||||
}
|
||||
|
||||
export class CoordinatesConverter implements ICoordinatesConverter {
|
||||
@@ -114,8 +116,8 @@ export class CoordinatesConverter implements ICoordinatesConverter {
|
||||
}
|
||||
|
||||
public validateViewRange(viewRange: Range, expectedModelRange: Range): Range {
|
||||
var validViewStart = this._lines.validateViewPosition(viewRange.startLineNumber, viewRange.startColumn, expectedModelRange.getStartPosition());
|
||||
var validViewEnd = this._lines.validateViewPosition(viewRange.endLineNumber, viewRange.endColumn, expectedModelRange.getEndPosition());
|
||||
const validViewStart = this._lines.validateViewPosition(viewRange.startLineNumber, viewRange.startColumn, expectedModelRange.getStartPosition());
|
||||
const validViewEnd = this._lines.validateViewPosition(viewRange.endLineNumber, viewRange.endColumn, expectedModelRange.getEndPosition());
|
||||
return new Range(validViewStart.lineNumber, validViewStart.column, validViewEnd.lineNumber, validViewEnd.column);
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@ export class CoordinatesConverter implements ICoordinatesConverter {
|
||||
|
||||
export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
|
||||
private model: editorCommon.IModel;
|
||||
private model: ITextModel;
|
||||
private _validModelVersionId: number;
|
||||
|
||||
private wrappingColumn: number;
|
||||
@@ -154,7 +156,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
|
||||
private hiddenAreasIds: string[];
|
||||
|
||||
constructor(model: editorCommon.IModel, linePositionMapperFactory: ILineMapperFactory, tabSize: number, wrappingColumn: number, columnsForFullWidthChar: number, wrappingIndent: WrappingIndent) {
|
||||
constructor(model: ITextModel, linePositionMapperFactory: ILineMapperFactory, tabSize: number, wrappingColumn: number, columnsForFullWidthChar: number, wrappingIndent: WrappingIndent) {
|
||||
this.model = model;
|
||||
this._validModelVersionId = -1;
|
||||
this.tabSize = tabSize;
|
||||
@@ -177,7 +179,8 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
private _ensureValidState(): void {
|
||||
let modelVersion = this.model.getVersionId();
|
||||
if (modelVersion !== this._validModelVersionId) {
|
||||
throw new Error('SplitLinesCollection: attempt to access a \'newer\' model');
|
||||
// This is pretty bad, it means we lost track of the model...
|
||||
throw new Error(`ViewModel is out of sync with Model!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,10 +221,10 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
this.prefixSumComputer = new PrefixSumComputerWithCache(values);
|
||||
}
|
||||
|
||||
private getHiddenAreas(): Range[] {
|
||||
public getHiddenAreas(): Range[] {
|
||||
return this.hiddenAreasIds.map((decId) => {
|
||||
return this.model.getDecorationRange(decId);
|
||||
}).sort(Range.compareRangesUsingStarts);
|
||||
});
|
||||
}
|
||||
|
||||
private _reduceRanges(_ranges: Range[]): Range[] {
|
||||
@@ -270,7 +273,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
}
|
||||
// END TODO@Martin: Please stop calling this method on each model change!
|
||||
|
||||
let newDecorations: editorCommon.IModelDeltaDecoration[] = [];
|
||||
let newDecorations: IModelDeltaDecoration[] = [];
|
||||
for (let i = 0; i < newRanges.length; i++) {
|
||||
newDecorations.push({
|
||||
range: newRanges[i],
|
||||
@@ -285,6 +288,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
let hiddenAreaIdx = -1;
|
||||
let nextLineNumberToUpdateHiddenArea = (hiddenAreaIdx + 1 < hiddenAreas.length) ? hiddenAreaEnd + 1 : this.lines.length + 2;
|
||||
|
||||
let hasVisibleLine = false;
|
||||
for (let i = 0; i < this.lines.length; i++) {
|
||||
let lineNumber = i + 1;
|
||||
|
||||
@@ -303,6 +307,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
lineChanged = true;
|
||||
}
|
||||
} else {
|
||||
hasVisibleLine = true;
|
||||
// Line should be visible
|
||||
if (!this.lines[i].isVisible()) {
|
||||
this.lines[i] = this.lines[i].setVisible(true);
|
||||
@@ -315,6 +320,11 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasVisibleLine) {
|
||||
// Cannot have everything be hidden => reveal everything!
|
||||
this.setHiddenAreas([]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -403,6 +413,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
insertPrefixSumValues[i] = outputLineCount;
|
||||
}
|
||||
|
||||
// TODO@Alex: use arrays.arrayInsert
|
||||
this.lines = this.lines.slice(0, fromLineNumber - 1).concat(insertLines).concat(this.lines.slice(fromLineNumber - 1));
|
||||
|
||||
this.prefixSumComputer.insertValues(fromLineNumber - 1, insertPrefixSumValues);
|
||||
@@ -461,6 +472,10 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
|
||||
public acceptVersionId(versionId: number): void {
|
||||
this._validModelVersionId = versionId;
|
||||
if (this.lines.length === 1 && !this.lines[0].isVisible()) {
|
||||
// At least one line must be visible => reset hidden areas
|
||||
this.setHiddenAreas([]);
|
||||
}
|
||||
}
|
||||
|
||||
public getViewLineCount(): number {
|
||||
@@ -735,7 +750,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
return result.result;
|
||||
}
|
||||
|
||||
public getDecorationsInRange(range: Range, ownerId: number, filterOutValidation: boolean): editorCommon.IModelDecoration[] {
|
||||
public getDecorationsInRange(range: Range, ownerId: number, filterOutValidation: boolean): IModelDecoration[] {
|
||||
const modelStart = this.convertViewPositionToModelPosition(range.startLineNumber, range.startColumn);
|
||||
const modelEnd = this.convertViewPositionToModelPosition(range.endLineNumber, range.endColumn);
|
||||
|
||||
@@ -744,7 +759,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
return this.model.getDecorationsInRange(new Range(modelStart.lineNumber, modelStart.column, modelEnd.lineNumber, modelEnd.column), ownerId, filterOutValidation);
|
||||
}
|
||||
|
||||
let result: editorCommon.IModelDecoration[] = [];
|
||||
let result: IModelDecoration[] = [];
|
||||
const modelStartLineIndex = modelStart.lineNumber - 1;
|
||||
const modelEndLineIndex = modelEnd.lineNumber - 1;
|
||||
|
||||
@@ -796,19 +811,19 @@ class VisibleIdentitySplitLine implements ISplitLine {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public getViewLineContent(model: IModel, modelLineNumber: number, outputLineIndex: number): string {
|
||||
public getViewLineContent(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): string {
|
||||
return model.getLineContent(modelLineNumber);
|
||||
}
|
||||
|
||||
public getViewLineMinColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
public getViewLineMinColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
return model.getLineMinColumn(modelLineNumber);
|
||||
}
|
||||
|
||||
public getViewLineMaxColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
public getViewLineMaxColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
return model.getLineMaxColumn(modelLineNumber);
|
||||
}
|
||||
|
||||
public getViewLineData(model: IModel, modelLineNumber: number, outputLineIndex: number): ViewLineData {
|
||||
public getViewLineData(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): ViewLineData {
|
||||
let lineTokens = model.getLineTokens(modelLineNumber);
|
||||
let lineContent = lineTokens.getLineContent();
|
||||
return new ViewLineData(
|
||||
@@ -819,7 +834,7 @@ class VisibleIdentitySplitLine implements ISplitLine {
|
||||
);
|
||||
}
|
||||
|
||||
public getViewLinesData(model: IModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
public getViewLinesData(model: ISimpleModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
if (!needed[globalStartIndex]) {
|
||||
result[globalStartIndex] = null;
|
||||
return;
|
||||
@@ -861,23 +876,23 @@ class InvisibleIdentitySplitLine implements ISplitLine {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public getViewLineContent(model: IModel, modelLineNumber: number, outputLineIndex: number): string {
|
||||
public getViewLineContent(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): string {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
||||
public getViewLineMinColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
public getViewLineMinColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
||||
public getViewLineMaxColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
public getViewLineMaxColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
||||
public getViewLineData(model: IModel, modelLineNumber: number, outputLineIndex: number): ViewLineData {
|
||||
public getViewLineData(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): ViewLineData {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
||||
public getViewLinesData(model: IModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
public getViewLinesData(model: ISimpleModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
||||
@@ -931,20 +946,25 @@ export class SplitLine implements ISplitLine {
|
||||
return this.positionMapper.getInputOffsetOfOutputPosition(outputLineIndex, 0);
|
||||
}
|
||||
|
||||
private getInputEndOffsetOfOutputLineIndex(model: IModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
private getInputEndOffsetOfOutputLineIndex(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
if (outputLineIndex + 1 === this.outputLineCount) {
|
||||
return model.getLineMaxColumn(modelLineNumber) - 1;
|
||||
}
|
||||
return this.positionMapper.getInputOffsetOfOutputPosition(outputLineIndex + 1, 0);
|
||||
}
|
||||
|
||||
public getViewLineContent(model: IModel, modelLineNumber: number, outputLineIndex: number): string {
|
||||
public getViewLineContent(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): string {
|
||||
if (!this._isVisible) {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
let startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex);
|
||||
let endOffset = this.getInputEndOffsetOfOutputLineIndex(model, modelLineNumber, outputLineIndex);
|
||||
let r = model.getLineContent(modelLineNumber).substring(startOffset, endOffset);
|
||||
let r = model.getValueInRange({
|
||||
startLineNumber: modelLineNumber,
|
||||
startColumn: startOffset + 1,
|
||||
endLineNumber: modelLineNumber,
|
||||
endColumn: endOffset + 1
|
||||
});
|
||||
|
||||
if (outputLineIndex > 0) {
|
||||
r = this.wrappedIndent + r;
|
||||
@@ -953,7 +973,7 @@ export class SplitLine implements ISplitLine {
|
||||
return r;
|
||||
}
|
||||
|
||||
public getViewLineMinColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
public getViewLineMinColumn(model: ITextModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
if (!this._isVisible) {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
@@ -963,14 +983,14 @@ export class SplitLine implements ISplitLine {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public getViewLineMaxColumn(model: IModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
public getViewLineMaxColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
if (!this._isVisible) {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
return this.getViewLineContent(model, modelLineNumber, outputLineIndex).length + 1;
|
||||
}
|
||||
|
||||
public getViewLineData(model: IModel, modelLineNumber: number, outputLineIndex: number): ViewLineData {
|
||||
public getViewLineData(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): ViewLineData {
|
||||
if (!this._isVisible) {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
@@ -978,7 +998,13 @@ export class SplitLine implements ISplitLine {
|
||||
let startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex);
|
||||
let endOffset = this.getInputEndOffsetOfOutputLineIndex(model, modelLineNumber, outputLineIndex);
|
||||
|
||||
let lineContent = model.getLineContent(modelLineNumber).substring(startOffset, endOffset);
|
||||
let lineContent = model.getValueInRange({
|
||||
startLineNumber: modelLineNumber,
|
||||
startColumn: startOffset + 1,
|
||||
endLineNumber: modelLineNumber,
|
||||
endColumn: endOffset + 1
|
||||
});
|
||||
|
||||
if (outputLineIndex > 0) {
|
||||
lineContent = this.wrappedIndent + lineContent;
|
||||
}
|
||||
@@ -1000,7 +1026,7 @@ export class SplitLine implements ISplitLine {
|
||||
);
|
||||
}
|
||||
|
||||
public getViewLinesData(model: IModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
public getViewLinesData(model: ITextModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
if (!this._isVisible) {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
@@ -1125,9 +1151,9 @@ export class IdentityCoordinatesConverter implements ICoordinatesConverter {
|
||||
|
||||
export class IdentityLinesCollection implements IViewModelLinesCollection {
|
||||
|
||||
public readonly model: editorCommon.IModel;
|
||||
public readonly model: ITextModel;
|
||||
|
||||
constructor(model: editorCommon.IModel) {
|
||||
constructor(model: ITextModel) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
@@ -1138,6 +1164,10 @@ export class IdentityLinesCollection implements IViewModelLinesCollection {
|
||||
return new IdentityCoordinatesConverter(this);
|
||||
}
|
||||
|
||||
public getHiddenAreas(): Range[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public setHiddenAreas(_ranges: Range[]): boolean {
|
||||
return false;
|
||||
}
|
||||
@@ -1243,7 +1273,7 @@ export class IdentityLinesCollection implements IViewModelLinesCollection {
|
||||
return result.result;
|
||||
}
|
||||
|
||||
public getDecorationsInRange(range: Range, ownerId: number, filterOutValidation: boolean): editorCommon.IModelDecoration[] {
|
||||
public getDecorationsInRange(range: Range, ownerId: number, filterOutValidation: boolean): IModelDecoration[] {
|
||||
return this.model.getDecorationsInRange(range, ownerId, filterOutValidation);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user