mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-26 01:38:40 +01:00
Small perf tweaks
This commit is contained in:
@@ -219,7 +219,7 @@ export interface ILayoutProvider extends IVerticalLayoutProvider, IScrollingProv
|
||||
|
||||
getCenteredViewLineNumberInViewport(): number;
|
||||
|
||||
getCurrentViewport(): editorCommon.IViewport;
|
||||
getCurrentViewport(): editorCommon.Viewport;
|
||||
|
||||
onMaxLineWidthChanged(width:number): void;
|
||||
|
||||
|
||||
@@ -104,13 +104,13 @@ export class LayoutProvider extends ViewEventHandler implements IDisposable, ILa
|
||||
|
||||
// ---- Layouting logic
|
||||
|
||||
public getCurrentViewport(): editorCommon.IViewport {
|
||||
return {
|
||||
top: this.scrollable.getScrollTop(),
|
||||
left: this.scrollable.getScrollLeft(),
|
||||
width: this.scrollable.getWidth(),
|
||||
height: this.scrollable.getHeight()
|
||||
};
|
||||
public getCurrentViewport(): editorCommon.Viewport {
|
||||
return new editorCommon.Viewport(
|
||||
this.scrollable.getScrollTop(),
|
||||
this.scrollable.getScrollLeft(),
|
||||
this.scrollable.getWidth(),
|
||||
this.scrollable.getHeight()
|
||||
);
|
||||
}
|
||||
|
||||
public getCenteredViewLineNumberInViewport(): number {
|
||||
|
||||
@@ -442,7 +442,7 @@ export class ViewLines extends ViewLayer {
|
||||
}
|
||||
}
|
||||
|
||||
private _computeScrollTopToRevealRange(viewport:editorCommon.IViewport, range: editorCommon.IEditorRange, verticalType: editorCommon.VerticalRevealType): number {
|
||||
private _computeScrollTopToRevealRange(viewport:editorCommon.Viewport, range: editorCommon.IEditorRange, verticalType: editorCommon.VerticalRevealType): number {
|
||||
var viewportStartY = viewport.top,
|
||||
viewportHeight = viewport.height,
|
||||
viewportEndY = viewportStartY + viewportHeight,
|
||||
@@ -529,8 +529,13 @@ export class ViewLines extends ViewLayer {
|
||||
}
|
||||
|
||||
private _computeMinimumScrolling(viewportStart: number, viewportEnd: number, boxStart: number, boxEnd: number): number {
|
||||
var viewportLength = viewportEnd - viewportStart,
|
||||
boxLength = boxEnd - boxStart;
|
||||
viewportStart = viewportStart|0;
|
||||
viewportEnd = viewportEnd|0;
|
||||
boxStart = boxStart|0;
|
||||
boxEnd = boxEnd|0;
|
||||
|
||||
let viewportLength = viewportEnd - viewportStart;
|
||||
let boxLength = boxEnd - boxStart;
|
||||
|
||||
if (boxLength < viewportLength) {
|
||||
// The box would fit in the viewport
|
||||
|
||||
@@ -175,7 +175,9 @@ class ZoneManager {
|
||||
if (!colorZonesInvalid) {
|
||||
let colorZones = zone.getColorZones();
|
||||
if (colorZones) {
|
||||
allColorZones = allColorZones.concat(colorZones);
|
||||
for (let j = 0, lenJ = colorZones.length; j < lenJ; j++) {
|
||||
allColorZones.push(colorZones[j]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +214,9 @@ class ZoneManager {
|
||||
}
|
||||
|
||||
zone.setColorZones(colorZones);
|
||||
allColorZones = allColorZones.concat(colorZones);
|
||||
for (let j = 0, lenJ = colorZones.length; j < lenJ; j++) {
|
||||
allColorZones.push(colorZones[j]);
|
||||
}
|
||||
}
|
||||
|
||||
this._colorZonesInvalid = false;
|
||||
@@ -389,14 +393,16 @@ export class OverviewRulerImpl {
|
||||
let ctx = this._domNode.getContext('2d');
|
||||
ctx.clearRect (0, 0, width, height);
|
||||
|
||||
let remainingWidth = width - this._canvasLeftOffset;
|
||||
if (colorZones.length > 0) {
|
||||
let remainingWidth = width - this._canvasLeftOffset;
|
||||
|
||||
if (this._lanesCount >= 3) {
|
||||
this._renderThreeLanes(ctx, colorZones, id2Color, remainingWidth);
|
||||
} else if (this._lanesCount === 2) {
|
||||
this._renderTwoLanes(ctx, colorZones, id2Color, remainingWidth);
|
||||
} else if (this._lanesCount === 1) {
|
||||
this._renderOneLane(ctx, colorZones, id2Color, remainingWidth);
|
||||
if (this._lanesCount >= 3) {
|
||||
this._renderThreeLanes(ctx, colorZones, id2Color, remainingWidth);
|
||||
} else if (this._lanesCount === 2) {
|
||||
this._renderTwoLanes(ctx, colorZones, id2Color, remainingWidth);
|
||||
} else if (this._lanesCount === 1) {
|
||||
this._renderOneLane(ctx, colorZones, id2Color, remainingWidth);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -488,13 +488,27 @@ export enum EditCursorState {
|
||||
EndOfLastEditOperation = 0
|
||||
}
|
||||
|
||||
class SingleEditOperation {
|
||||
|
||||
range: editorCommon.IEditorRange;
|
||||
text: string;
|
||||
forceMoveMarkers: boolean;
|
||||
|
||||
constructor(source:editorCommon.ISingleEditOperation) {
|
||||
this.range = new Range(source.range.startLineNumber, source.range.startColumn, source.range.endLineNumber, source.range.endColumn);
|
||||
this.text = source.text;
|
||||
this.forceMoveMarkers = source.forceMoveMarkers || false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class CommandRunner implements editorCommon.ICommand {
|
||||
|
||||
private _ops: editorCommon.ISingleEditOperation[];
|
||||
private _ops: SingleEditOperation[];
|
||||
private _editCursorState: EditCursorState;
|
||||
|
||||
constructor(ops: editorCommon.ISingleEditOperation[], editCursorState: EditCursorState) {
|
||||
this._ops = ops;
|
||||
this._ops = ops.map(op => new SingleEditOperation(op));
|
||||
this._editCursorState = editCursorState;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,27 +127,27 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
|
||||
this.lineNumbers = input.lineNumbers || false;
|
||||
this.selectOnLineNumbers = Boolean(input.selectOnLineNumbers);
|
||||
this.glyphMargin = Boolean(input.glyphMargin);
|
||||
this.revealHorizontalRightPadding = Number(input.revealHorizontalRightPadding);
|
||||
this.revealHorizontalRightPadding = Number(input.revealHorizontalRightPadding)|0;
|
||||
this.roundedSelection = Boolean(input.roundedSelection);
|
||||
this.theme = String(input.theme);
|
||||
this.readOnly = Boolean(input.readOnly);
|
||||
this.scrollbar = {
|
||||
arrowSize: Number(input.scrollbar.arrowSize),
|
||||
arrowSize: Number(input.scrollbar.arrowSize)|0,
|
||||
vertical: String(input.scrollbar.vertical),
|
||||
horizontal: String(input.scrollbar.horizontal),
|
||||
useShadows: Boolean(input.scrollbar.useShadows),
|
||||
verticalHasArrows: Boolean(input.scrollbar.verticalHasArrows),
|
||||
horizontalHasArrows: Boolean(input.scrollbar.horizontalHasArrows),
|
||||
handleMouseWheel: Boolean(input.scrollbar.handleMouseWheel),
|
||||
horizontalScrollbarSize: Number(input.scrollbar.horizontalScrollbarSize),
|
||||
horizontalSliderSize: Number(input.scrollbar.horizontalSliderSize),
|
||||
verticalScrollbarSize: Number(input.scrollbar.verticalScrollbarSize),
|
||||
verticalSliderSize: Number(input.scrollbar.verticalSliderSize),
|
||||
mouseWheelScrollSensitivity: Number(input.scrollbar.mouseWheelScrollSensitivity),
|
||||
horizontalScrollbarSize: Number(input.scrollbar.horizontalScrollbarSize)|0,
|
||||
horizontalSliderSize: Number(input.scrollbar.horizontalSliderSize)|0,
|
||||
verticalScrollbarSize: Number(input.scrollbar.verticalScrollbarSize)|0,
|
||||
verticalSliderSize: Number(input.scrollbar.verticalSliderSize)|0,
|
||||
mouseWheelScrollSensitivity: Number(input.scrollbar.mouseWheelScrollSensitivity)|0,
|
||||
};
|
||||
this.overviewRulerLanes = Number(input.overviewRulerLanes);
|
||||
this.overviewRulerLanes = Number(input.overviewRulerLanes)|0;
|
||||
this.cursorBlinking = String(input.cursorBlinking);
|
||||
this.cursorStyle = Number(input.cursorStyle);
|
||||
this.cursorStyle = Number(input.cursorStyle)|0;
|
||||
this.fontLigatures = Boolean(input.fontLigatures);
|
||||
this.hideCursorInOverviewRuler = Boolean(input.hideCursorInOverviewRuler);
|
||||
this.scrollBeyondLastLine = Boolean(input.scrollBeyondLastLine);
|
||||
@@ -156,14 +156,14 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
|
||||
this.wordWrapBreakAfterCharacters = String(input.wordWrapBreakAfterCharacters);
|
||||
this.wordWrapBreakObtrusiveCharacters = String(input.wordWrapBreakObtrusiveCharacters);
|
||||
this.tabFocusMode = Boolean(input.tabFocusMode);
|
||||
this.stopLineTokenizationAfter = Number(input.stopLineTokenizationAfter);
|
||||
this.stopRenderingLineAfter = Number(input.stopRenderingLineAfter);
|
||||
this.longLineBoundary = Number(input.longLineBoundary);
|
||||
this.forcedTokenizationBoundary = Number(input.forcedTokenizationBoundary);
|
||||
this.stopLineTokenizationAfter = Number(input.stopLineTokenizationAfter)|0;
|
||||
this.stopRenderingLineAfter = Number(input.stopRenderingLineAfter)|0;
|
||||
this.longLineBoundary = Number(input.longLineBoundary)|0;
|
||||
this.forcedTokenizationBoundary = Number(input.forcedTokenizationBoundary)|0;
|
||||
this.hover = Boolean(input.hover);
|
||||
this.contextmenu = Boolean(input.contextmenu);
|
||||
this.quickSuggestions = Boolean(input.quickSuggestions);
|
||||
this.quickSuggestionsDelay = Number(input.quickSuggestionsDelay);
|
||||
this.quickSuggestionsDelay = Number(input.quickSuggestionsDelay)|0;
|
||||
this.iconsInSuggestions = Boolean(input.iconsInSuggestions);
|
||||
this.autoClosingBrackets = Boolean(input.autoClosingBrackets);
|
||||
this.formatOnType = Boolean(input.formatOnType);
|
||||
@@ -175,46 +175,46 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
|
||||
this.folding = Boolean(input.folding);
|
||||
this.renderWhitespace = Boolean(input.renderWhitespace);
|
||||
this.layoutInfo = {
|
||||
width: Number(input.layoutInfo.width),
|
||||
height: Number(input.layoutInfo.height),
|
||||
glyphMarginLeft: Number(input.layoutInfo.glyphMarginLeft),
|
||||
glyphMarginWidth: Number(input.layoutInfo.glyphMarginWidth),
|
||||
glyphMarginHeight: Number(input.layoutInfo.glyphMarginHeight),
|
||||
lineNumbersLeft: Number(input.layoutInfo.lineNumbersLeft),
|
||||
lineNumbersWidth: Number(input.layoutInfo.lineNumbersWidth),
|
||||
lineNumbersHeight: Number(input.layoutInfo.lineNumbersHeight),
|
||||
decorationsLeft: Number(input.layoutInfo.decorationsLeft),
|
||||
decorationsWidth: Number(input.layoutInfo.decorationsWidth),
|
||||
decorationsHeight: Number(input.layoutInfo.decorationsHeight),
|
||||
contentLeft: Number(input.layoutInfo.contentLeft),
|
||||
contentWidth: Number(input.layoutInfo.contentWidth),
|
||||
contentHeight: Number(input.layoutInfo.contentHeight),
|
||||
verticalScrollbarWidth: Number(input.layoutInfo.verticalScrollbarWidth),
|
||||
horizontalScrollbarHeight: Number(input.layoutInfo.horizontalScrollbarHeight),
|
||||
width: Number(input.layoutInfo.width)|0,
|
||||
height: Number(input.layoutInfo.height)|0,
|
||||
glyphMarginLeft: Number(input.layoutInfo.glyphMarginLeft)|0,
|
||||
glyphMarginWidth: Number(input.layoutInfo.glyphMarginWidth)|0,
|
||||
glyphMarginHeight: Number(input.layoutInfo.glyphMarginHeight)|0,
|
||||
lineNumbersLeft: Number(input.layoutInfo.lineNumbersLeft)|0,
|
||||
lineNumbersWidth: Number(input.layoutInfo.lineNumbersWidth)|0,
|
||||
lineNumbersHeight: Number(input.layoutInfo.lineNumbersHeight)|0,
|
||||
decorationsLeft: Number(input.layoutInfo.decorationsLeft)|0,
|
||||
decorationsWidth: Number(input.layoutInfo.decorationsWidth)|0,
|
||||
decorationsHeight: Number(input.layoutInfo.decorationsHeight)|0,
|
||||
contentLeft: Number(input.layoutInfo.contentLeft)|0,
|
||||
contentWidth: Number(input.layoutInfo.contentWidth)|0,
|
||||
contentHeight: Number(input.layoutInfo.contentHeight)|0,
|
||||
verticalScrollbarWidth: Number(input.layoutInfo.verticalScrollbarWidth)|0,
|
||||
horizontalScrollbarHeight: Number(input.layoutInfo.horizontalScrollbarHeight)|0,
|
||||
overviewRuler:{
|
||||
width: Number(input.layoutInfo.overviewRuler.width),
|
||||
height: Number(input.layoutInfo.overviewRuler.height),
|
||||
top: Number(input.layoutInfo.overviewRuler.top),
|
||||
right: Number(input.layoutInfo.overviewRuler.right),
|
||||
width: Number(input.layoutInfo.overviewRuler.width)|0,
|
||||
height: Number(input.layoutInfo.overviewRuler.height)|0,
|
||||
top: Number(input.layoutInfo.overviewRuler.top)|0,
|
||||
right: Number(input.layoutInfo.overviewRuler.right)|0,
|
||||
}
|
||||
};
|
||||
this.stylingInfo = {
|
||||
editorClassName: String(input.stylingInfo.editorClassName),
|
||||
fontFamily: String(input.stylingInfo.fontFamily),
|
||||
fontSize: Number(input.stylingInfo.fontSize),
|
||||
lineHeight: Number(input.stylingInfo.lineHeight),
|
||||
fontSize: Number(input.stylingInfo.fontSize)|0,
|
||||
lineHeight: Number(input.stylingInfo.lineHeight)|0,
|
||||
};
|
||||
this.wrappingInfo = {
|
||||
isViewportWrapping: Boolean(input.wrappingInfo.isViewportWrapping),
|
||||
wrappingColumn: Number(input.wrappingInfo.wrappingColumn),
|
||||
wrappingColumn: Number(input.wrappingInfo.wrappingColumn)|0,
|
||||
};
|
||||
this.observedOuterWidth = Number(input.observedOuterWidth);
|
||||
this.observedOuterHeight = Number(input.observedOuterHeight);
|
||||
this.lineHeight = Number(input.lineHeight);
|
||||
this.pageSize = Number(input.pageSize);
|
||||
this.observedOuterWidth = Number(input.observedOuterWidth)|0;
|
||||
this.observedOuterHeight = Number(input.observedOuterHeight)|0;
|
||||
this.lineHeight = Number(input.lineHeight)|0;
|
||||
this.pageSize = Number(input.pageSize)|0;
|
||||
this.typicalHalfwidthCharacterWidth = Number(input.typicalHalfwidthCharacterWidth);
|
||||
this.typicalFullwidthCharacterWidth = Number(input.typicalFullwidthCharacterWidth);
|
||||
this.fontSize = Number(input.fontSize);
|
||||
this.fontSize = Number(input.fontSize)|0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -224,17 +224,26 @@ export class Range implements IEditorRange {
|
||||
* A function that compares ranges, useful for sorting ranges
|
||||
* It will first compare ranges on the startPosition and then on the endPosition
|
||||
*/
|
||||
public static compareRangesUsingStarts(a:IRange, b:IRange): number {
|
||||
if (a.startLineNumber === b.startLineNumber) {
|
||||
if (a.startColumn === b.startColumn) {
|
||||
if (a.endLineNumber === b.endLineNumber) {
|
||||
return a.endColumn - b.endColumn;
|
||||
public static compareRangesUsingStarts(a:IEditorRange, b:IEditorRange): number {
|
||||
let aStartLineNumber = a.startLineNumber|0;
|
||||
let bStartLineNumber = b.startLineNumber|0;
|
||||
let aStartColumn = a.startColumn|0;
|
||||
let bStartColumn = b.startColumn|0;
|
||||
let aEndLineNumber = a.endLineNumber|0;
|
||||
let bEndLineNumber = b.endLineNumber|0;
|
||||
let aEndColumn = a.endColumn|0;
|
||||
let bEndColumn = b.endColumn|0;
|
||||
|
||||
if (aStartLineNumber === bStartLineNumber) {
|
||||
if (aStartColumn === bStartColumn) {
|
||||
if (aEndLineNumber === bEndLineNumber) {
|
||||
return aEndColumn - bEndColumn;
|
||||
}
|
||||
return a.endLineNumber - b.endLineNumber;
|
||||
return aEndLineNumber - bEndLineNumber;
|
||||
}
|
||||
return a.startColumn - b.startColumn;
|
||||
return aStartColumn - bStartColumn;
|
||||
}
|
||||
return a.startLineNumber - b.startLineNumber;
|
||||
return aStartLineNumber - bStartLineNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -873,7 +873,7 @@ export interface IModelTrackedRange {
|
||||
/**
|
||||
* Range that this tracked range covers
|
||||
*/
|
||||
range: IRange;
|
||||
range: IEditorRange;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -891,7 +891,7 @@ export interface IModelDecoration {
|
||||
/**
|
||||
* Range that this decoration covers.
|
||||
*/
|
||||
range: IRange;
|
||||
range: IEditorRange;
|
||||
/**
|
||||
* Options associated with this decoration.
|
||||
*/
|
||||
@@ -2780,11 +2780,20 @@ export class ViewLinesViewportData {
|
||||
}
|
||||
}
|
||||
|
||||
export interface IViewport {
|
||||
export class Viewport {
|
||||
_viewportTrait: void;
|
||||
|
||||
top: number;
|
||||
left: number;
|
||||
width: number;
|
||||
height: number;
|
||||
|
||||
constructor(top:number, left:number, width:number, height:number) {
|
||||
this.top = top|0;
|
||||
this.left = left|0;
|
||||
this.width = width|0;
|
||||
this.height = height|0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3487,9 +3496,9 @@ export class VisibleRange {
|
||||
public width:number;
|
||||
|
||||
constructor(top:number, left:number, width:number) {
|
||||
this.top = top;
|
||||
this.left = left;
|
||||
this.width = width;
|
||||
this.top = top|0;
|
||||
this.left = left|0;
|
||||
this.width = width|0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,9 +65,15 @@ enum MarkerMoveSemantics {
|
||||
}
|
||||
|
||||
export class ModelLine {
|
||||
public lineNumber:number;
|
||||
public text:string;
|
||||
public isInvalid:boolean;
|
||||
private _lineNumber:number;
|
||||
public get lineNumber():number { return this._lineNumber; }
|
||||
|
||||
private _text:string;
|
||||
public get text():string { return this._text; }
|
||||
|
||||
private _isInvalid:boolean;
|
||||
public get isInvalid():boolean { return this._isInvalid; }
|
||||
public set isInvalid(value:boolean) { this._isInvalid = value; }
|
||||
|
||||
private _state:IState;
|
||||
private _modeTransitions:ModeTransition[];
|
||||
@@ -75,9 +81,9 @@ export class ModelLine {
|
||||
private _markers:ILineMarker[];
|
||||
|
||||
constructor(lineNumber:number, text:string) {
|
||||
this.lineNumber = lineNumber;
|
||||
this.text = text;
|
||||
this.isInvalid = false;
|
||||
this._lineNumber = lineNumber|0;
|
||||
this._text = text;
|
||||
this._isInvalid = false;
|
||||
this._state = null;
|
||||
this._modeTransitions = null;
|
||||
this._lineTokens = null;
|
||||
@@ -123,14 +129,14 @@ export class ModelLine {
|
||||
}
|
||||
|
||||
private _setLineTokensFromInflated(map:ITokensInflatorMap, tokens:IToken[]): void {
|
||||
let desired = toLineTokensFromInflated(map, tokens, this.text.length);
|
||||
let desired = toLineTokensFromInflated(map, tokens, this._text.length);
|
||||
|
||||
|
||||
this._lineTokens = desired;
|
||||
}
|
||||
|
||||
private _setLineTokensFromDeflated(map:ITokensInflatorMap, tokens:number[]): void {
|
||||
let desired = toLineTokensFromDeflated(map, tokens, this.text.length);
|
||||
let desired = toLineTokensFromDeflated(map, tokens, this._text.length);
|
||||
|
||||
|
||||
this._lineTokens = desired;
|
||||
@@ -140,7 +146,7 @@ export class ModelLine {
|
||||
if (this._lineTokens) {
|
||||
return this._lineTokens;
|
||||
}
|
||||
if (this.text.length === 0) {
|
||||
if (this._text.length === 0) {
|
||||
return EmptyLineTokens.INSTANCE;
|
||||
}
|
||||
return DefaultLineTokens.INSTANCE;
|
||||
@@ -213,13 +219,13 @@ export class ModelLine {
|
||||
}
|
||||
|
||||
private _setText(text:string): void {
|
||||
this.text = text;
|
||||
this._text = text;
|
||||
|
||||
if (this._lineTokens) {
|
||||
let BIN = TokensBinaryEncoding,
|
||||
map = this._lineTokens.getBinaryEncodedTokensMap(),
|
||||
tokens = this._lineTokens.getBinaryEncodedTokens(),
|
||||
lineTextLength = this.text.length;
|
||||
lineTextLength = this._text.length;
|
||||
|
||||
// Remove overflowing tokens
|
||||
while (tokens.length > 0) {
|
||||
@@ -298,7 +304,7 @@ export class ModelLine {
|
||||
let newColumn = Math.max(minimumAllowedColumn, marker.column + delta);
|
||||
if (marker.column !== newColumn) {
|
||||
changedMarkers[marker.id] = true;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this.lineNumber;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this._lineNumber;
|
||||
marker.oldColumn = marker.oldColumn || marker.column;
|
||||
marker.column = newColumn;
|
||||
}
|
||||
@@ -321,7 +327,7 @@ export class ModelLine {
|
||||
while (markersIndex < markersLength && adjustMarkerBeforeColumn(toColumn, moveSemantics)) {
|
||||
if (marker.column !== newColumn) {
|
||||
changedMarkers[marker.id] = true;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this.lineNumber;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this._lineNumber;
|
||||
marker.oldColumn = marker.oldColumn || marker.column;
|
||||
marker.column = newColumn;
|
||||
}
|
||||
@@ -350,7 +356,7 @@ export class ModelLine {
|
||||
|
||||
public applyEdits(changedMarkers: IChangedMarkers, edits:ILineEdit[]): number {
|
||||
let deltaColumn = 0;
|
||||
let resultText = this.text;
|
||||
let resultText = this._text;
|
||||
|
||||
let tokensAdjuster = this._createTokensAdjuster();
|
||||
let markersAdjuster = this._createMarkersAdjuster(changedMarkers);
|
||||
@@ -406,8 +412,8 @@ export class ModelLine {
|
||||
|
||||
public split(changedMarkers: IChangedMarkers, splitColumn:number, forceMoveMarkers:boolean): ModelLine {
|
||||
// console.log('--> split @ ' + splitColumn + '::: ' + this._printMarkers());
|
||||
var myText = this.text.substring(0, splitColumn - 1);
|
||||
var otherText = this.text.substring(splitColumn - 1);
|
||||
var myText = this._text.substring(0, splitColumn - 1);
|
||||
var otherText = this._text.substring(splitColumn - 1);
|
||||
|
||||
var otherMarkers: ILineMarker[] = null;
|
||||
|
||||
@@ -438,7 +444,7 @@ export class ModelLine {
|
||||
let marker = otherMarkers[i];
|
||||
|
||||
changedMarkers[marker.id] = true;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this.lineNumber;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this._lineNumber;
|
||||
marker.oldColumn = marker.oldColumn || marker.column;
|
||||
marker.column -= splitColumn - 1;
|
||||
}
|
||||
@@ -447,7 +453,7 @@ export class ModelLine {
|
||||
|
||||
this._setText(myText);
|
||||
|
||||
var otherLine = new ModelLine(this.lineNumber + 1, otherText);
|
||||
var otherLine = new ModelLine(this._lineNumber + 1, otherText);
|
||||
if (otherMarkers) {
|
||||
otherLine.addMarkers(otherMarkers);
|
||||
}
|
||||
@@ -457,8 +463,8 @@ export class ModelLine {
|
||||
public append(changedMarkers: IChangedMarkers, other:ModelLine): void {
|
||||
// console.log('--> append: THIS :: ' + this._printMarkers());
|
||||
// console.log('--> append: OTHER :: ' + this._printMarkers());
|
||||
var thisTextLength = this.text.length;
|
||||
this._setText(this.text + other.text);
|
||||
var thisTextLength = this._text.length;
|
||||
this._setText(this._text + other._text);
|
||||
|
||||
let otherLineTokens = other._lineTokens;
|
||||
if (otherLineTokens) {
|
||||
@@ -587,11 +593,11 @@ export class ModelLine {
|
||||
marker = markers[i];
|
||||
|
||||
changedMarkers[marker.id] = true;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this.lineNumber;
|
||||
marker.oldLineNumber = marker.oldLineNumber || this._lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
this.lineNumber = newLineNumber;
|
||||
this._lineNumber = newLineNumber;
|
||||
}
|
||||
|
||||
public deleteLine(changedMarkers: IChangedMarkers, setMarkersColumn:number, setMarkersOldLineNumber:number): ILineMarker[] {
|
||||
|
||||
@@ -114,7 +114,7 @@ export class LinesLayout {
|
||||
* @param reserveHorizontalScrollbarHeight The height of the horizontal scrollbar.
|
||||
* @return Basically, the `scrollHeight` for the editor content.
|
||||
*/
|
||||
public getTotalHeight(viewport:editorCommon.IViewport, reserveHorizontalScrollbarHeight:number): number {
|
||||
public getTotalHeight(viewport:editorCommon.Viewport, reserveHorizontalScrollbarHeight:number): number {
|
||||
var totalLinesHeight = this.getLinesTotalHeight();
|
||||
|
||||
// if (this.context.configuration.editor.autoSize) {
|
||||
@@ -162,7 +162,7 @@ export class LinesLayout {
|
||||
* @param viewport The viewport.
|
||||
* @return An array with all the whitespaces in the viewport. If no whitespace is in viewport, the array is empty.
|
||||
*/
|
||||
public getWhitespaceViewportData(visibleBox:editorCommon.IViewport): editorCommon.IViewWhitespaceViewportData[] {
|
||||
public getWhitespaceViewportData(visibleBox:editorCommon.Viewport): editorCommon.IViewWhitespaceViewportData[] {
|
||||
return this.verticalObjects.getWhitespaceViewportData(visibleBox.top, visibleBox.top + visibleBox.height, this._lineHeight);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ export class LinesLayout {
|
||||
* @param viewport The viewport.
|
||||
* @return A structure describing the lines positioned between `verticalOffset1` and `verticalOffset2`.
|
||||
*/
|
||||
public getLinesViewportData(visibleBox:editorCommon.IViewport): editorCommon.ViewLinesViewportData {
|
||||
public getLinesViewportData(visibleBox:editorCommon.Viewport): editorCommon.ViewLinesViewportData {
|
||||
let partialData = this.verticalObjects.getLinesViewportData(visibleBox.top, visibleBox.top + visibleBox.height, this._lineHeight);
|
||||
let decorationsData = this.model.getDecorationsViewportData(partialData.startLineNumber, partialData.endLineNumber);
|
||||
let visibleRange = new Range(
|
||||
@@ -205,7 +205,7 @@ export class LinesLayout {
|
||||
* @param viewport The viewport.
|
||||
* @return The line number that is closest to the center of `viewport`.
|
||||
*/
|
||||
public getCenteredLineInViewport(visibleBox:editorCommon.IViewport): number {
|
||||
public getCenteredLineInViewport(visibleBox:editorCommon.Viewport): number {
|
||||
return this.verticalObjects.getCenteredLineInViewport(visibleBox.top, visibleBox.top + visibleBox.height, this._lineHeight);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import {Arrays} from 'vs/editor/common/core/arrays';
|
||||
import {LineToken, IRange, IViewLineTokens} from 'vs/editor/common/editorCommon';
|
||||
import {LineToken, IEditorRange, IViewLineTokens} from 'vs/editor/common/editorCommon';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
||||
export interface ILineParts {
|
||||
@@ -56,8 +56,8 @@ function insertWhitespace(lineNumber:number, lineContent: string, fauxIndentLeng
|
||||
return rawLineDecorations;
|
||||
}
|
||||
|
||||
var prepend: IRange = null,
|
||||
append: IRange = null,
|
||||
var prepend: IEditorRange = null,
|
||||
append: IEditorRange = null,
|
||||
computeTrailing = true;
|
||||
|
||||
var firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
|
||||
@@ -67,19 +67,9 @@ function insertWhitespace(lineNumber:number, lineContent: string, fauxIndentLeng
|
||||
if (firstNonWhitespaceIndex === -1) {
|
||||
// The entire string is whitespace
|
||||
computeTrailing = false;
|
||||
prepend = {
|
||||
startLineNumber: lineNumber,
|
||||
endLineNumber: lineNumber,
|
||||
startColumn: 1,
|
||||
endColumn: lineContent.length + 1
|
||||
};
|
||||
prepend = new Range(lineNumber, 1, lineNumber, lineContent.length + 1);
|
||||
} else {
|
||||
prepend = {
|
||||
startLineNumber: lineNumber,
|
||||
endLineNumber: lineNumber,
|
||||
startColumn: 1,
|
||||
endColumn: firstNonWhitespaceIndex + 1
|
||||
};
|
||||
prepend = new Range(lineNumber, 1, lineNumber, firstNonWhitespaceIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,12 +87,7 @@ function insertWhitespace(lineNumber:number, lineContent: string, fauxIndentLeng
|
||||
if (lastNonWhitespaceIndex !== lineContent.length - 1) {
|
||||
// There is trailing whitespace
|
||||
// No need to handle the case that the entire string is empty, since it is handled above
|
||||
append = {
|
||||
startLineNumber: lineNumber,
|
||||
endLineNumber: lineNumber,
|
||||
startColumn: lastNonWhitespaceIndex + 2,
|
||||
endColumn: lineContent.length + 1
|
||||
};
|
||||
append = new Range(lineNumber, lastNonWhitespaceIndex + 2, lineNumber, lineContent.length + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +302,7 @@ class Stack {
|
||||
}
|
||||
|
||||
export interface ILineDecoration {
|
||||
range: IRange;
|
||||
range: IEditorRange;
|
||||
options: {
|
||||
inlineClassName?: string;
|
||||
};
|
||||
|
||||
@@ -26,11 +26,11 @@ interface IViewModelDecorationSource {
|
||||
class ViewModelDecoration implements IViewModelDecoration {
|
||||
id: string;
|
||||
ownerId: number;
|
||||
range: editorCommon.IRange;
|
||||
range: editorCommon.IEditorRange;
|
||||
options: editorCommon.IModelDecorationOptions;
|
||||
modelRange: editorCommon.IRange;
|
||||
|
||||
constructor(source:IViewModelDecorationSource, range:editorCommon.IRange) {
|
||||
constructor(source:IViewModelDecorationSource, range:editorCommon.IEditorRange) {
|
||||
this.id = source.id;
|
||||
this.options = source.options;
|
||||
this.ownerId = source.ownerId;
|
||||
|
||||
@@ -518,7 +518,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
if (!symbols) {
|
||||
symbols = [];
|
||||
} else {
|
||||
symbols = symbols.sort((a, b) => Range.compareRangesUsingStarts(a.symbol.range, b.symbol.range));
|
||||
symbols = symbols.sort((a, b) => Range.compareRangesUsingStarts(Range.lift(a.symbol.range), Range.lift(b.symbol.range)));
|
||||
}
|
||||
|
||||
let maxLineNumber = this._editor.getModel().getLineCount();
|
||||
|
||||
@@ -76,6 +76,18 @@ class LinkOccurence {
|
||||
}
|
||||
}
|
||||
|
||||
class Link {
|
||||
range: editorCommon.IEditorRange;
|
||||
url: string;
|
||||
extraInlineClassName: string;
|
||||
|
||||
constructor(source:ILink) {
|
||||
this.range = new Range(source.range.startLineNumber, source.range.startColumn, source.range.endLineNumber, source.range.endColumn);
|
||||
this.url = source.url;
|
||||
this.extraInlineClassName = source.extraInlineClassName || null;
|
||||
}
|
||||
}
|
||||
|
||||
class LinkDetector {
|
||||
static RECOMPUTE_TIME = 1000; // ms
|
||||
static TRIGGER_KEY_VALUE = platform.isMacintosh ? KeyCode.Meta : KeyCode.Ctrl;
|
||||
@@ -174,7 +186,7 @@ class LinkDetector {
|
||||
if (!b || b.length === 0) {
|
||||
return a || [];
|
||||
}
|
||||
return LinkDetector._linksUnion(a, b);
|
||||
return LinkDetector._linksUnion(a.map(el => new Link(el)), b.map(el => new Link(el)));
|
||||
});
|
||||
|
||||
this.computePromise.then((links:ILink[]) => {
|
||||
@@ -183,15 +195,15 @@ class LinkDetector {
|
||||
});
|
||||
}
|
||||
|
||||
private static _linksUnion(oldLinks: ILink[], newLinks: ILink[]): ILink[] {
|
||||
private static _linksUnion(oldLinks: Link[], newLinks: Link[]): Link[] {
|
||||
// reunite oldLinks with newLinks and remove duplicates
|
||||
var result: ILink[] = [],
|
||||
var result: Link[] = [],
|
||||
oldIndex: number,
|
||||
oldLen: number,
|
||||
newIndex: number,
|
||||
newLen: number,
|
||||
oldLink: ILink,
|
||||
newLink: ILink,
|
||||
oldLink: Link,
|
||||
newLink: Link,
|
||||
comparisonResult: number;
|
||||
|
||||
for (oldIndex = 0, newIndex = 0, oldLen = oldLinks.length, newLen = newLinks.length; oldIndex < oldLen && newIndex < newLen;) {
|
||||
|
||||
@@ -65,7 +65,7 @@ export function getOutlineEntries(model: IModel): TPromise<IOutline> {
|
||||
}
|
||||
|
||||
function compareEntriesUsingStart(a: IOutlineEntry, b: IOutlineEntry): number{
|
||||
return Range.compareRangesUsingStarts(a.range, b.range);
|
||||
return Range.compareRangesUsingStarts(Range.lift(a.range), Range.lift(b.range));
|
||||
}
|
||||
|
||||
function flatten(bucket: IOutlineEntry[], entries: IOutlineEntry[], overrideContainerLabel: string): void {
|
||||
|
||||
@@ -6,17 +6,13 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import {DecorationSegment, ILineDecoration, LineDecorationsNormalizer} from 'vs/editor/common/viewLayout/viewLineParts';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
||||
suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
|
||||
function newDecoration(startLineNumber:number, startColumn:number, endLineNumber:number, endColumn:number, inlineClassName:string): ILineDecoration {
|
||||
return {
|
||||
range: {
|
||||
startLineNumber: startLineNumber,
|
||||
startColumn: startColumn,
|
||||
endLineNumber: endLineNumber,
|
||||
endColumn: endColumn
|
||||
},
|
||||
range: new Range(startLineNumber, startColumn, endLineNumber, endColumn),
|
||||
options: {
|
||||
inlineClassName: inlineClassName
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import paths = require('vs/base/common/paths');
|
||||
import lifecycle = require('vs/base/common/lifecycle');
|
||||
import collections = require('vs/base/common/collections');
|
||||
import {EventEmitter} from 'vs/base/common/eventEmitter';
|
||||
import {IModel, ITextModel, IModelDeltaDecoration, EventType, OverviewRulerLane, TrackedRangeStickiness, IModelDecorationOptions, IRange} from 'vs/editor/common/editorCommon';
|
||||
import {IModel, ITextModel, IModelDeltaDecoration, EventType, OverviewRulerLane, TrackedRangeStickiness, IModelDecorationOptions, IEditorRange} from 'vs/editor/common/editorCommon';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {IModelService} from 'vs/editor/common/services/modelService';
|
||||
import * as Search from 'vs/platform/search/common/search';
|
||||
@@ -21,7 +21,7 @@ export class Match {
|
||||
private _parent: FileMatch;
|
||||
private _lineText: string;
|
||||
private _id: string;
|
||||
private _range: IRange;
|
||||
private _range: IEditorRange;
|
||||
|
||||
constructor(parent: FileMatch, text: string, lineNumber: number, offset: number, length: number) {
|
||||
this._parent = parent;
|
||||
@@ -42,7 +42,7 @@ export class Match {
|
||||
return this._lineText;
|
||||
}
|
||||
|
||||
public range(): IRange {
|
||||
public range(): IEditorRange {
|
||||
return this._range;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user