提交 bc6d7655 编写于 作者: A Alex Dima

More optimizations

上级 521d200b
...@@ -4,6 +4,178 @@ ...@@ -4,6 +4,178 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
'use strict'; 'use strict';
export abstract class FastDomNode {
private _domNode: HTMLElement;
private _maxWidth: number;
private _width: number;
private _height: number;
private _top: number;
private _left: number;
private _bottom: number;
private _right: number;
private _fontSize: number;
private _lineHeight: number;
private _display: string;
private _visibility: string;
private _transform: string;
private _lineNumber: string;
public get domNode(): HTMLElement {
return this._domNode;
}
constructor(domNode: HTMLElement) {
this._domNode = domNode;
this._maxWidth = -1;
this._width = -1;
this._height = -1;
this._top = -1;
this._left = -1;
this._bottom = -1;
this._right = -1;
this._fontSize = -1;
this._lineHeight = -1;
this._display = '';
this._visibility = '';
this._transform = '';
this._lineNumber = '';
}
public setMaxWidth(maxWidth: number): void {
if (this._maxWidth === maxWidth) {
return;
}
this._maxWidth = maxWidth;
this._domNode.style.maxWidth = this._maxWidth + 'px';
}
public setWidth(width: number): void {
if (this._width === width) {
return;
}
this._width = width;
this._domNode.style.width = this._width + 'px';
}
public setHeight(height: number): void {
if (this._height === height) {
return;
}
this._height = height;
this._domNode.style.height = this._height + 'px';
}
public setTop(top: number): void {
if (this._top === top) {
return;
}
this._top = top;
this._domNode.style.top = this._top + 'px';
}
public setLeft(left: number): void {
if (this._left === left) {
return;
}
this._left = left;
this._domNode.style.left = this._left + 'px';
}
public setBottom(bottom: number): void {
if (this._bottom === bottom) {
return;
}
this._bottom = bottom;
this._domNode.style.bottom = this._bottom + 'px';
}
public setRight(right: number): void {
if (this._right === right) {
return;
}
this._right = right;
this._domNode.style.right = this._right + 'px';
}
public setFontSize(fontSize: number): void {
if (this._fontSize === fontSize) {
return;
}
this._fontSize = fontSize;
this._domNode.style.fontSize = this._fontSize + 'px';
}
public setLineHeight(lineHeight: number): void {
if (this._lineHeight === lineHeight) {
return;
}
this._lineHeight = lineHeight;
this._domNode.style.lineHeight = this._lineHeight + 'px';
}
public setDisplay(display: string): void {
if (this._display === display) {
return;
}
this._display = display;
this._domNode.style.display = this._display;
}
public setVisibility(visibility: string): void {
if (this._visibility === visibility) {
return;
}
this._visibility = visibility;
this._domNode.style.visibility = this._visibility;
}
public setTransform(transform:string): void {
if (this._transform === transform) {
return;
}
this._transform = transform;
this._setTransform(this._domNode, this._transform);
}
protected abstract _setTransform(domNode:HTMLElement, transform:string): void;
public setLineNumber(lineNumber:string): void {
if (this._lineNumber === lineNumber) {
return;
}
this._lineNumber = lineNumber;
this._domNode.setAttribute('lineNumber', this._lineNumber);
}
}
class WebKitFastDomNode extends FastDomNode {
protected _setTransform(domNode:HTMLElement, transform:string): void {
(<any>domNode.style).webkitTransform = transform;
}
}
class StandardFastDomNode extends FastDomNode {
protected _setTransform(domNode:HTMLElement, transform:string): void {
domNode.style.transform = transform;
}
}
let useWebKitFastDomNode = false;
(function() {
let testDomNode = document.createElement('div');
if (typeof (<any>testDomNode.style).webkitTransform !== 'undefined') {
useWebKitFastDomNode = true;
}
})();
export function createFastDomNode(domNode: HTMLElement): FastDomNode {
if (useWebKitFastDomNode) {
return new WebKitFastDomNode(domNode);
} else {
return new StandardFastDomNode(domNode);
}
}
export const StyleMutator = { export const StyleMutator = {
setMaxWidth: (domNode: HTMLElement, maxWidth: number) => { setMaxWidth: (domNode: HTMLElement, maxWidth: number) => {
let desiredValue = maxWidth + 'px'; let desiredValue = maxWidth + 'px';
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
'use strict'; 'use strict';
import * as browser from 'vs/base/browser/browser'; import * as browser from 'vs/base/browser/browser';
import {StyleMutator} from 'vs/base/browser/styleMutator'; import {FastDomNode, createFastDomNode} from 'vs/base/browser/styleMutator';
import {HorizontalRange, IConfigurationChangedEvent, IModelDecoration} from 'vs/editor/common/editorCommon'; import {HorizontalRange, IConfigurationChangedEvent, IModelDecoration} from 'vs/editor/common/editorCommon';
import {ILineParts, createLineParts} from 'vs/editor/common/viewLayout/viewLineParts'; import {ILineParts, createLineParts} from 'vs/editor/common/viewLayout/viewLineParts';
import {renderLine, RenderLineInput} from 'vs/editor/common/viewLayout/viewLineRenderer'; import {renderLine, RenderLineInput} from 'vs/editor/common/viewLayout/viewLineRenderer';
...@@ -15,7 +15,7 @@ import {IVisibleLineData} from 'vs/editor/browser/view/viewLayer'; ...@@ -15,7 +15,7 @@ import {IVisibleLineData} from 'vs/editor/browser/view/viewLayer';
export class ViewLine implements IVisibleLineData { export class ViewLine implements IVisibleLineData {
protected _context:IViewContext; protected _context:IViewContext;
private _domNode: HTMLElement; private _domNode: FastDomNode;
private _lineParts: ILineParts; private _lineParts: ILineParts;
...@@ -39,10 +39,13 @@ export class ViewLine implements IVisibleLineData { ...@@ -39,10 +39,13 @@ export class ViewLine implements IVisibleLineData {
// --- begin IVisibleLineData // --- begin IVisibleLineData
public getDomNode(): HTMLElement { public getDomNode(): HTMLElement {
return this._domNode; if (!this._domNode) {
return null;
}
return this._domNode.domNode;
} }
public setDomNode(domNode:HTMLElement): void { public setDomNode(domNode:HTMLElement): void {
this._domNode = domNode; this._domNode = createFastDomNode(domNode);
} }
public onContentChanged(): void { public onContentChanged(): void {
...@@ -119,13 +122,9 @@ export class ViewLine implements IVisibleLineData { ...@@ -119,13 +122,9 @@ export class ViewLine implements IVisibleLineData {
} }
public layoutLine(lineNumber:number, deltaTop:number): void { public layoutLine(lineNumber:number, deltaTop:number): void {
let desiredLineNumber = String(lineNumber); this._domNode.setLineNumber(String(lineNumber));
let currentLineNumber = this._domNode.getAttribute('lineNumber'); this._domNode.setTop(deltaTop);
if (currentLineNumber !== desiredLineNumber) { this._domNode.setHeight(this._context.configuration.editor.lineHeight);
this._domNode.setAttribute('lineNumber', desiredLineNumber);
}
StyleMutator.setTop(this._domNode, deltaTop);
StyleMutator.setHeight(this._domNode, this._context.configuration.editor.lineHeight);
} }
// --- end IVisibleLineData // --- end IVisibleLineData
...@@ -151,7 +150,7 @@ export class ViewLine implements IVisibleLineData { ...@@ -151,7 +150,7 @@ export class ViewLine implements IVisibleLineData {
// --- Reading from the DOM methods // --- Reading from the DOM methods
protected _getReadingTarget(): HTMLElement { protected _getReadingTarget(): HTMLElement {
return <HTMLSpanElement>this._domNode.firstChild; return <HTMLSpanElement>this._domNode.domNode.firstChild;
} }
/** /**
......
...@@ -62,105 +62,160 @@ export class ConfigurationWithDefaults { ...@@ -62,105 +62,160 @@ export class ConfigurationWithDefaults {
} }
} }
function cloneInternalEditorOptions(opts: editorCommon.IInternalEditorOptions): editorCommon.IInternalEditorOptions { export class InternalEditorOptions implements editorCommon.IInternalEditorOptions {
return { public _internalEditorOptionsTrait: void;
experimentalScreenReader: opts.experimentalScreenReader,
rulers: opts.rulers.slice(0), experimentalScreenReader: boolean;
wordSeparators: opts.wordSeparators, rulers: number[];
selectionClipboard: opts.selectionClipboard, wordSeparators: string;
ariaLabel: opts.ariaLabel, selectionClipboard: boolean;
lineNumbers: opts.lineNumbers, ariaLabel: string;
selectOnLineNumbers: opts.selectOnLineNumbers, lineNumbers:any;
glyphMargin: opts.glyphMargin, selectOnLineNumbers:boolean;
revealHorizontalRightPadding: opts.revealHorizontalRightPadding, glyphMargin:boolean;
roundedSelection: opts.roundedSelection, revealHorizontalRightPadding:number;
theme: opts.theme, roundedSelection:boolean;
readOnly: opts.readOnly, theme:string;
scrollbar: { readOnly:boolean;
arrowSize: opts.scrollbar.arrowSize, scrollbar:editorCommon.IInternalEditorScrollbarOptions;
vertical: opts.scrollbar.vertical, overviewRulerLanes:number;
horizontal: opts.scrollbar.horizontal, cursorBlinking:string;
useShadows: opts.scrollbar.useShadows, cursorStyle:editorCommon.TextEditorCursorStyle;
verticalHasArrows: opts.scrollbar.verticalHasArrows, fontLigatures:boolean;
horizontalHasArrows: opts.scrollbar.horizontalHasArrows, hideCursorInOverviewRuler:boolean;
handleMouseWheel: opts.scrollbar.handleMouseWheel, scrollBeyondLastLine:boolean;
horizontalScrollbarSize: opts.scrollbar.horizontalScrollbarSize, wrappingIndent: string;
horizontalSliderSize: opts.scrollbar.horizontalSliderSize, wordWrapBreakBeforeCharacters: string;
verticalScrollbarSize: opts.scrollbar.verticalScrollbarSize, wordWrapBreakAfterCharacters: string;
verticalSliderSize: opts.scrollbar.verticalSliderSize, wordWrapBreakObtrusiveCharacters: string;
mouseWheelScrollSensitivity: opts.scrollbar.mouseWheelScrollSensitivity, tabFocusMode:boolean;
}, stopLineTokenizationAfter:number;
overviewRulerLanes: opts.overviewRulerLanes, stopRenderingLineAfter: number;
cursorBlinking: opts.cursorBlinking, longLineBoundary:number;
cursorStyle: opts.cursorStyle, forcedTokenizationBoundary:number;
fontLigatures: opts.fontLigatures, hover:boolean;
hideCursorInOverviewRuler: opts.hideCursorInOverviewRuler, contextmenu:boolean;
scrollBeyondLastLine: opts.scrollBeyondLastLine, quickSuggestions:boolean;
wrappingIndent: opts.wrappingIndent, quickSuggestionsDelay:number;
wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters, iconsInSuggestions:boolean;
wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters, autoClosingBrackets:boolean;
wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters, formatOnType:boolean;
tabFocusMode: opts.tabFocusMode, suggestOnTriggerCharacters: boolean;
stopLineTokenizationAfter: opts.stopLineTokenizationAfter, acceptSuggestionOnEnter: boolean;
stopRenderingLineAfter: opts.stopRenderingLineAfter, selectionHighlight:boolean;
longLineBoundary: opts.longLineBoundary, outlineMarkers: boolean;
forcedTokenizationBoundary: opts.forcedTokenizationBoundary, referenceInfos: boolean;
hover: opts.hover, folding: boolean;
contextmenu: opts.contextmenu, renderWhitespace: boolean;
quickSuggestions: opts.quickSuggestions, layoutInfo: editorCommon.IEditorLayoutInfo;
quickSuggestionsDelay: opts.quickSuggestionsDelay, stylingInfo: editorCommon.IEditorStyling;
iconsInSuggestions: opts.iconsInSuggestions, wrappingInfo: editorCommon.IEditorWrappingInfo;
autoClosingBrackets: opts.autoClosingBrackets, observedOuterWidth:number;
formatOnType: opts.formatOnType, observedOuterHeight:number;
suggestOnTriggerCharacters: opts.suggestOnTriggerCharacters, lineHeight:number;
acceptSuggestionOnEnter: opts.acceptSuggestionOnEnter, pageSize:number;
selectionHighlight: opts.selectionHighlight, typicalHalfwidthCharacterWidth:number;
outlineMarkers: opts.outlineMarkers, typicalFullwidthCharacterWidth:number;
referenceInfos: opts.referenceInfos, fontSize:number;
folding: opts.folding,
renderWhitespace: opts.renderWhitespace, constructor(input:editorCommon.IInternalEditorOptions) {
layoutInfo: { this.experimentalScreenReader = Boolean(input.experimentalScreenReader);
width: opts.layoutInfo.width, this.rulers = Array.prototype.slice.call(input.rulers, 0);
height: opts.layoutInfo.height, this.wordSeparators = String(input.wordSeparators);
glyphMarginLeft: opts.layoutInfo.glyphMarginLeft, this.selectionClipboard = Boolean(input.selectionClipboard);
glyphMarginWidth: opts.layoutInfo.glyphMarginWidth, this.ariaLabel = String(input.ariaLabel);
glyphMarginHeight: opts.layoutInfo.glyphMarginHeight, this.lineNumbers = input.lineNumbers || false;
lineNumbersLeft: opts.layoutInfo.lineNumbersLeft, this.selectOnLineNumbers = Boolean(input.selectOnLineNumbers);
lineNumbersWidth: opts.layoutInfo.lineNumbersWidth, this.glyphMargin = Boolean(input.glyphMargin);
lineNumbersHeight: opts.layoutInfo.lineNumbersHeight, this.revealHorizontalRightPadding = Number(input.revealHorizontalRightPadding);
decorationsLeft: opts.layoutInfo.decorationsLeft, this.roundedSelection = Boolean(input.roundedSelection);
decorationsWidth: opts.layoutInfo.decorationsWidth, this.theme = String(input.theme);
decorationsHeight: opts.layoutInfo.decorationsHeight, this.readOnly = Boolean(input.readOnly);
contentLeft: opts.layoutInfo.contentLeft, this.scrollbar = {
contentWidth: opts.layoutInfo.contentWidth, arrowSize: Number(input.scrollbar.arrowSize),
contentHeight: opts.layoutInfo.contentHeight, vertical: String(input.scrollbar.vertical),
verticalScrollbarWidth: opts.layoutInfo.verticalScrollbarWidth, horizontal: String(input.scrollbar.horizontal),
horizontalScrollbarHeight: opts.layoutInfo.horizontalScrollbarHeight, 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),
};
this.overviewRulerLanes = Number(input.overviewRulerLanes);
this.cursorBlinking = String(input.cursorBlinking);
this.cursorStyle = Number(input.cursorStyle);
this.fontLigatures = Boolean(input.fontLigatures);
this.hideCursorInOverviewRuler = Boolean(input.hideCursorInOverviewRuler);
this.scrollBeyondLastLine = Boolean(input.scrollBeyondLastLine);
this.wrappingIndent = String(input.wrappingIndent);
this.wordWrapBreakBeforeCharacters = String(input.wordWrapBreakBeforeCharacters);
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.hover = Boolean(input.hover);
this.contextmenu = Boolean(input.contextmenu);
this.quickSuggestions = Boolean(input.quickSuggestions);
this.quickSuggestionsDelay = Number(input.quickSuggestionsDelay);
this.iconsInSuggestions = Boolean(input.iconsInSuggestions);
this.autoClosingBrackets = Boolean(input.autoClosingBrackets);
this.formatOnType = Boolean(input.formatOnType);
this.suggestOnTriggerCharacters = Boolean(input.suggestOnTriggerCharacters);
this.acceptSuggestionOnEnter = Boolean(input.acceptSuggestionOnEnter);
this.selectionHighlight = Boolean(input.selectionHighlight);
this.outlineMarkers = Boolean(input.outlineMarkers);
this.referenceInfos = Boolean(input.referenceInfos);
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),
overviewRuler:{ overviewRuler:{
width: opts.layoutInfo.overviewRuler.width, width: Number(input.layoutInfo.overviewRuler.width),
height: opts.layoutInfo.overviewRuler.height, height: Number(input.layoutInfo.overviewRuler.height),
top: opts.layoutInfo.overviewRuler.top, top: Number(input.layoutInfo.overviewRuler.top),
right: opts.layoutInfo.overviewRuler.right, right: Number(input.layoutInfo.overviewRuler.right),
} }
}, };
stylingInfo: { this.stylingInfo = {
editorClassName: opts.stylingInfo.editorClassName, editorClassName: String(input.stylingInfo.editorClassName),
fontFamily: opts.stylingInfo.fontFamily, fontFamily: String(input.stylingInfo.fontFamily),
fontSize: opts.stylingInfo.fontSize, fontSize: Number(input.stylingInfo.fontSize),
lineHeight: opts.stylingInfo.lineHeight, lineHeight: Number(input.stylingInfo.lineHeight),
}, };
wrappingInfo: { this.wrappingInfo = {
isViewportWrapping: opts.wrappingInfo.isViewportWrapping, isViewportWrapping: Boolean(input.wrappingInfo.isViewportWrapping),
wrappingColumn: opts.wrappingInfo.wrappingColumn, wrappingColumn: Number(input.wrappingInfo.wrappingColumn),
}, };
observedOuterWidth: opts.observedOuterWidth, this.observedOuterWidth = Number(input.observedOuterWidth);
observedOuterHeight: opts.observedOuterHeight, this.observedOuterHeight = Number(input.observedOuterHeight);
lineHeight: opts.lineHeight, this.lineHeight = Number(input.lineHeight);
pageSize: opts.pageSize, this.pageSize = Number(input.pageSize);
typicalHalfwidthCharacterWidth: opts.typicalHalfwidthCharacterWidth, this.typicalHalfwidthCharacterWidth = Number(input.typicalHalfwidthCharacterWidth);
typicalFullwidthCharacterWidth: opts.typicalFullwidthCharacterWidth, this.typicalFullwidthCharacterWidth = Number(input.typicalFullwidthCharacterWidth);
fontSize: opts.fontSize, this.fontSize = Number(input.fontSize);
}; }
} }
class InternalEditorOptionsHelper { class InternalEditorOptionsHelper {
...@@ -548,8 +603,8 @@ export interface IElementSizeObserver { ...@@ -548,8 +603,8 @@ export interface IElementSizeObserver {
export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration {
public handlerDispatcher:editorCommon.IHandlerDispatcher; public handlerDispatcher:editorCommon.IHandlerDispatcher;
public editor:editorCommon.IInternalEditorOptions; public editor:InternalEditorOptions;
public editorClone:editorCommon.IInternalEditorOptions; public editorClone:InternalEditorOptions;
protected _configWithDefaults:ConfigurationWithDefaults; protected _configWithDefaults:ConfigurationWithDefaults;
protected _elementSizeObserver: IElementSizeObserver; protected _elementSizeObserver: IElementSizeObserver;
...@@ -569,7 +624,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -569,7 +624,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
this.handlerDispatcher = new HandlerDispatcher(); this.handlerDispatcher = new HandlerDispatcher();
this.editor = this._computeInternalOptions(); this.editor = this._computeInternalOptions();
this.editorClone = cloneInternalEditorOptions(this.editor); this.editorClone = new InternalEditorOptions(this.editor);
} }
public dispose(): void { public dispose(): void {
...@@ -579,7 +634,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -579,7 +634,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
protected _recomputeOptions(): void { protected _recomputeOptions(): void {
let oldOpts = this.editor; let oldOpts = this.editor;
this.editor = this._computeInternalOptions(); this.editor = this._computeInternalOptions();
this.editorClone = cloneInternalEditorOptions(this.editor); this.editorClone = new InternalEditorOptions(this.editor);
let changeEvent = InternalEditorOptionsHelper.createConfigurationChangedEvent(oldOpts, this.editor); let changeEvent = InternalEditorOptionsHelper.createConfigurationChangedEvent(oldOpts, this.editor);
...@@ -602,7 +657,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -602,7 +657,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
return this._configWithDefaults.getEditorOptions(); return this._configWithDefaults.getEditorOptions();
} }
private _computeInternalOptions(): editorCommon.IInternalEditorOptions { private _computeInternalOptions(): InternalEditorOptions {
let opts = this._configWithDefaults.getEditorOptions(); let opts = this._configWithDefaults.getEditorOptions();
let editorClassName = this._getEditorClassName(opts.theme, toBoolean(opts.fontLigatures)); let editorClassName = this._getEditorClassName(opts.theme, toBoolean(opts.fontLigatures));
...@@ -615,7 +670,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -615,7 +670,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
adjustedLineHeight = Math.round(1.3 * requestedFontSize); adjustedLineHeight = Math.round(1.3 * requestedFontSize);
} }
return InternalEditorOptionsHelper.createInternalEditorOptions( let result = InternalEditorOptionsHelper.createInternalEditorOptions(
this.getOuterWidth(), this.getOuterWidth(),
this.getOuterHeight(), this.getOuterHeight(),
opts, opts,
...@@ -628,6 +683,8 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -628,6 +683,8 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
this._isDominatedByLongLines, this._isDominatedByLongLines,
this._lineCount this._lineCount
); );
return new InternalEditorOptions(result);
} }
public updateOptions(newOptions:editorCommon.IEditorOptions): void { public updateOptions(newOptions:editorCommon.IEditorOptions): void {
......
...@@ -104,14 +104,6 @@ export class ModelLine { ...@@ -104,14 +104,6 @@ export class ModelLine {
private _setModeTransitions(topLevelMode:IMode, modeTransitions:IModeTransition[]): void { private _setModeTransitions(topLevelMode:IMode, modeTransitions:IModeTransition[]): void {
let desired = toModeTransitions(topLevelMode, modeTransitions); let desired = toModeTransitions(topLevelMode, modeTransitions);
if (desired === null) {
// saving memory
if (typeof this._modeTransitions === 'undefined') {
return;
}
this._modeTransitions = null;
return;
}
this._modeTransitions = desired; this._modeTransitions = desired;
} }
...@@ -135,14 +127,6 @@ export class ModelLine { ...@@ -135,14 +127,6 @@ export class ModelLine {
private _setLineTokensFromInflated(map:ITokensInflatorMap, tokens:IToken[]): void { private _setLineTokensFromInflated(map:ITokensInflatorMap, tokens:IToken[]): void {
let desired = toLineTokensFromInflated(map, tokens, this.text.length); let desired = toLineTokensFromInflated(map, tokens, this.text.length);
if (desired === null) {
// saving memory
if (typeof this._lineTokens === 'undefined') {
return;
}
this._lineTokens = null;
return;
}
this._lineTokens = desired; this._lineTokens = desired;
} }
...@@ -150,14 +134,6 @@ export class ModelLine { ...@@ -150,14 +134,6 @@ export class ModelLine {
private _setLineTokensFromDeflated(map:ITokensInflatorMap, tokens:number[]): void { private _setLineTokensFromDeflated(map:ITokensInflatorMap, tokens:number[]): void {
let desired = toLineTokensFromDeflated(map, tokens, this.text.length); let desired = toLineTokensFromDeflated(map, tokens, this.text.length);
if (desired === null) {
// saving memory
if (typeof this._lineTokens === 'undefined') {
return;
}
this._lineTokens = null;
return;
}
this._lineTokens = desired; this._lineTokens = desired;
} }
......
...@@ -213,13 +213,24 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke ...@@ -213,13 +213,24 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
super(allowedEventTypes, rawText); super(allowedEventTypes, rawText);
this._shouldAutoTokenize = shouldAutoTokenize; this._shouldAutoTokenize = shouldAutoTokenize;
this._shouldSimplifyMode = (rawText.length > TextModelWithTokens.MODEL_SYNC_LIMIT); this._mode = null;
this._shouldDenyMode = (rawText.length > TextModelWithTokens.MODEL_TOKENIZATION_LIMIT);
this._stopLineTokenizationAfter = DefaultConfig.editor.stopLineTokenizationAfter;
this._modeListener = null; this._modeListener = null;
this._modeToModelBinder = null; this._modeToModelBinder = null;
this._tokensInflatorMap = null;
this._stopLineTokenizationAfter = DefaultConfig.editor.stopLineTokenizationAfter;
this._invalidLineStartIndex = 0;
this._lastState = null;
this._revalidateTokensTimeout = -1;
this._scheduleRetokenizeNow = null;
this._retokenizers = null;
this._tokenizationElapsedTime = 0;
this._tokenizationTotalCharacters = 0;
this._shouldSimplifyMode = (rawText.length > TextModelWithTokens.MODEL_SYNC_LIMIT);
this._shouldDenyMode = (rawText.length > TextModelWithTokens.MODEL_TOKENIZATION_LIMIT);
if (!modeOrPromise) { if (!modeOrPromise) {
this._mode = new NullMode(); this._mode = new NullMode();
......
...@@ -66,7 +66,7 @@ export function renderLine(input:RenderLineInput): IRenderLineOutput { ...@@ -66,7 +66,7 @@ export function renderLine(input:RenderLineInput): IRenderLineOutput {
throw new Error('Cannot render non empty line without line parts!'); throw new Error('Cannot render non empty line without line parts!');
} }
return renderLineActual(lineText, lineTextLength, tabSize, actualLineParts, renderWhitespace, charBreakIndex); return renderLineActual(lineText, lineTextLength, tabSize, actualLineParts.slice(0), renderWhitespace, charBreakIndex);
} }
const WHITESPACE_TOKEN_TEST = /\bwhitespace\b/; const WHITESPACE_TOKEN_TEST = /\bwhitespace\b/;
......
...@@ -72,6 +72,11 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor ...@@ -72,6 +72,11 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
return null; return null;
} }
tabSize = +tabSize; //@perf
breakingColumn = +breakingColumn; //@perf
columnsForFullWidthChar = +columnsForFullWidthChar; //@perf
hardWrappingIndent = +hardWrappingIndent; //@perf
var wrappedTextIndentVisibleColumn = 0, var wrappedTextIndentVisibleColumn = 0,
wrappedTextIndent = '', wrappedTextIndent = '',
TAB_CHAR_CODE = '\t'.charCodeAt(0); TAB_CHAR_CODE = '\t'.charCodeAt(0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册