提交 99f6d9b8 编写于 作者: A Alex Dima

Small perf tweaks

上级 2b6b07f8
......@@ -198,7 +198,7 @@ export abstract class CommonCodeEditor extends EventEmitter.EventEmitter impleme
}
public getConfiguration(): EditorCommon.IInternalEditorOptions {
return Objects.clone(this._configuration.editor);
return this._configuration.editorClone;
}
public getRawConfiguration(): EditorCommon.IEditorOptions {
......@@ -206,7 +206,11 @@ export abstract class CommonCodeEditor extends EventEmitter.EventEmitter impleme
}
public getIndentationOptions(): EditorCommon.IInternalIndentationOptions {
return Objects.clone(this._configuration.getIndentationOptions());
let r = this._configuration.getIndentationOptions();
return {
tabSize: r.tabSize,
insertSpaces: r.insertSpaces
};
}
public normalizeIndentation(str:string): string {
......@@ -643,6 +647,7 @@ export abstract class CommonCodeEditor extends EventEmitter.EventEmitter impleme
this._decorationTypeKeysToIds[decorationTypeKey] = this.deltaDecorations(oldDecorationIds, ranges.map((r) : EditorCommon.IModelDeltaDecoration => {
let decOpts: EditorCommon.IModelDecorationOptions;
if (r.hoverMessage) {
// TODO@Alex: avoid Objects.clone
decOpts = Objects.clone(opts);
decOpts.htmlMessage = r.hoverMessage;
} else {
......
......@@ -62,6 +62,107 @@ export class ConfigurationWithDefaults {
}
}
function cloneInternalEditorOptions(opts: EditorCommon.IInternalEditorOptions): EditorCommon.IInternalEditorOptions {
return {
experimentalScreenReader: opts.experimentalScreenReader,
rulers: opts.rulers.slice(0),
ariaLabel: opts.ariaLabel,
lineNumbers: opts.lineNumbers,
selectOnLineNumbers: opts.selectOnLineNumbers,
glyphMargin: opts.glyphMargin,
revealHorizontalRightPadding: opts.revealHorizontalRightPadding,
roundedSelection: opts.roundedSelection,
theme: opts.theme,
readOnly: opts.readOnly,
scrollbar: {
arrowSize: opts.scrollbar.arrowSize,
vertical: opts.scrollbar.vertical,
horizontal: opts.scrollbar.horizontal,
useShadows: opts.scrollbar.useShadows,
verticalHasArrows: opts.scrollbar.verticalHasArrows,
horizontalHasArrows: opts.scrollbar.horizontalHasArrows,
handleMouseWheel: opts.scrollbar.handleMouseWheel,
horizontalScrollbarSize: opts.scrollbar.horizontalScrollbarSize,
horizontalSliderSize: opts.scrollbar.horizontalSliderSize,
verticalScrollbarSize: opts.scrollbar.verticalScrollbarSize,
verticalSliderSize: opts.scrollbar.verticalSliderSize,
mouseWheelScrollSensitivity: opts.scrollbar.mouseWheelScrollSensitivity,
},
overviewRulerLanes: opts.overviewRulerLanes,
cursorBlinking: opts.cursorBlinking,
cursorStyle: opts.cursorStyle,
fontLigatures: opts.fontLigatures,
hideCursorInOverviewRuler: opts.hideCursorInOverviewRuler,
scrollBeyondLastLine: opts.scrollBeyondLastLine,
wrappingIndent: opts.wrappingIndent,
wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
tabFocusMode: opts.tabFocusMode,
stopLineTokenizationAfter: opts.stopLineTokenizationAfter,
stopRenderingLineAfter: opts.stopRenderingLineAfter,
longLineBoundary: opts.longLineBoundary,
forcedTokenizationBoundary: opts.forcedTokenizationBoundary,
hover: opts.hover,
contextmenu: opts.contextmenu,
quickSuggestions: opts.quickSuggestions,
quickSuggestionsDelay: opts.quickSuggestionsDelay,
iconsInSuggestions: opts.iconsInSuggestions,
autoClosingBrackets: opts.autoClosingBrackets,
formatOnType: opts.formatOnType,
suggestOnTriggerCharacters: opts.suggestOnTriggerCharacters,
selectionHighlight: opts.selectionHighlight,
outlineMarkers: opts.outlineMarkers,
referenceInfos: opts.referenceInfos,
renderWhitespace: opts.renderWhitespace,
layoutInfo: {
width: opts.layoutInfo.width,
height: opts.layoutInfo.height,
glyphMarginLeft: opts.layoutInfo.glyphMarginLeft,
glyphMarginWidth: opts.layoutInfo.glyphMarginWidth,
glyphMarginHeight: opts.layoutInfo.glyphMarginHeight,
lineNumbersLeft: opts.layoutInfo.lineNumbersLeft,
lineNumbersWidth: opts.layoutInfo.lineNumbersWidth,
lineNumbersHeight: opts.layoutInfo.lineNumbersHeight,
decorationsLeft: opts.layoutInfo.decorationsLeft,
decorationsWidth: opts.layoutInfo.decorationsWidth,
decorationsHeight: opts.layoutInfo.decorationsHeight,
contentLeft: opts.layoutInfo.contentLeft,
contentWidth: opts.layoutInfo.contentWidth,
contentHeight: opts.layoutInfo.contentHeight,
verticalScrollbarWidth: opts.layoutInfo.verticalScrollbarWidth,
horizontalScrollbarHeight: opts.layoutInfo.horizontalScrollbarHeight,
overviewRuler:{
width: opts.layoutInfo.overviewRuler.width,
height: opts.layoutInfo.overviewRuler.height,
top: opts.layoutInfo.overviewRuler.top,
right: opts.layoutInfo.overviewRuler.right,
}
},
stylingInfo: {
editorClassName: opts.stylingInfo.editorClassName,
fontFamily: opts.stylingInfo.fontFamily,
fontSize: opts.stylingInfo.fontSize,
lineHeight: opts.stylingInfo.lineHeight,
},
wrappingInfo: {
isViewportWrapping: opts.wrappingInfo.isViewportWrapping,
wrappingColumn: opts.wrappingInfo.wrappingColumn,
},
indentInfo: {
tabSize: opts.indentInfo.tabSize,
insertSpaces: opts.indentInfo.insertSpaces,
},
observedOuterWidth: opts.observedOuterWidth,
observedOuterHeight: opts.observedOuterHeight,
lineHeight: opts.lineHeight,
pageSize: opts.pageSize,
typicalHalfwidthCharacterWidth: opts.typicalHalfwidthCharacterWidth,
typicalFullwidthCharacterWidth: opts.typicalFullwidthCharacterWidth,
fontSize: opts.fontSize,
};
}
class InternalEditorOptionsHelper {
constructor() {
......@@ -444,6 +545,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements Ed
public handlerDispatcher:EditorCommon.IHandlerDispatcher;
public editor:EditorCommon.IInternalEditorOptions;
public editorClone:EditorCommon.IInternalEditorOptions;
protected _configWithDefaults:ConfigurationWithDefaults;
private _indentationGuesser:IIndentationGuesser;
......@@ -467,6 +569,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements Ed
this.handlerDispatcher = new HandlerDispatcher();
this.editor = this._computeInternalOptions();
this.editorClone = cloneInternalEditorOptions(this.editor);
}
public dispose(): void {
......@@ -476,6 +579,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements Ed
protected _recomputeOptions(): void {
let oldOpts = this.editor;
this.editor = this._computeInternalOptions();
this.editorClone = cloneInternalEditorOptions(this.editor);
let changeEvent = InternalEditorOptionsHelper.createConfigurationChangedEvent(oldOpts, this.editor);
......
......@@ -155,6 +155,7 @@ export class Model extends EditableTextModel implements EditorCommon.IModel {
throw new Error('Model.getProperties: Model is disposed');
}
// TODO@Alex: avoid Objects.clone
return Objects.clone(this._extraProperties);
}
......
......@@ -8,7 +8,7 @@
import 'vs/css!./media/editorstatus';
import nls = require('vs/nls');
import {TPromise} from 'vs/base/common/winjs.base';
import { emmet as $, append, show, hide } from 'vs/base/browser/dom';
import { emmet as $, append } from 'vs/base/browser/dom';
import encoding = require('vs/base/common/bits/encoding');
import strings = require('vs/base/common/strings');
import types = require('vs/base/common/types');
......@@ -21,6 +21,7 @@ import {Registry} from 'vs/platform/platform';
import {UntitledEditorInput} from 'vs/workbench/common/editor/untitledEditorInput';
import {IFileEditorInput, EncodingMode, IEncodingSupport, asFileEditorInput, getUntitledOrFileResource} from 'vs/workbench/common/editor';
import {IDisposable, combinedDispose} from 'vs/base/common/lifecycle';
import {ICommonCodeEditor} from 'vs/editor/common/editorCommon';
import {ICodeEditor, IDiffEditor} from 'vs/editor/browser/editorBrowser';
import {EndOfLineSequence, ITokenizedModel, EditorType, IEditorSelection, ITextModel, IDiffEditorModel, IEditor} from 'vs/editor/common/editorCommon';
import {EventType, ResourceEvent, EditorEvent, TextEditorSelectionEvent} from 'vs/workbench/common/events';
......@@ -33,6 +34,21 @@ import {IEventService} from 'vs/platform/event/common/event';
import {IFilesConfiguration} from 'vs/platform/files/common/files';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IModeService} from 'vs/editor/common/services/modeService';
import {StyleMutator} from 'vs/base/browser/styleMutator';
function getCodeEditor(e: IBaseEditor): ICommonCodeEditor {
if (e instanceof BaseTextEditor) {
let editorWidget = e.getControl();
if (editorWidget.getEditorType() === EditorType.IDiffEditor) {
return (<IDiffEditor>editorWidget).getModifiedEditor();
}
if (editorWidget.getEditorType() === EditorType.ICodeEditor) {
return (<ICodeEditor>editorWidget);
}
return null;
}
return null;
}
function getTextModel(editorWidget: IEditor): ITextModel {
let textModel: ITextModel;
......@@ -165,6 +181,13 @@ const nlsEOLLF = nls.localize('endOfLineLineFeed', "LF");
const nlsEOLCRLF = nls.localize('endOfLineCarriageReturnLineFeed', "CRLF");
const nlsTabFocusMode = nls.localize('tabFocusModeEnabled', "Tab moves focus");
function show(el:HTMLElement): void {
StyleMutator.setDisplay(el, '');
}
function hide(el:HTMLElement): void {
StyleMutator.setDisplay(el, 'none');
}
export class EditorStatus implements IStatusbarItem {
private state: State;
......@@ -408,15 +431,15 @@ export class EditorStatus implements IStatusbarItem {
return;
}
let info: StateDelta = { EOL: null };
let codeEditor = getCodeEditor(e);
if (!codeEditor) {
return;
}
// We only support writable text based code editors
if (e instanceof BaseTextEditor && isWritableCodeEditor(e)) {
let editorWidget = e.getControl();
let textModel = getTextModel(editorWidget);
if (textModel) {
info = { EOL: textModel.getEOL() };
}
let info: StateDelta = { EOL: null };
if (!codeEditor.getConfiguration().readOnly) {
let codeEditorModel = codeEditor.getModel();
info.EOL = codeEditorModel.getEOL();
}
this.updateState(info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册