提交 26769ff0 编写于 作者: A Alex Dima

Convert IInternalEditorOptions to InternalEditorOptions

上级 a2f2f4b0
...@@ -40,7 +40,7 @@ export class ScrollManager implements IDisposable { ...@@ -40,7 +40,7 @@ export class ScrollManager implements IDisposable {
listenOnDomNode: viewDomNode, listenOnDomNode: viewDomNode,
vertical: configScrollbarOpts.vertical, vertical: configScrollbarOpts.vertical,
horizontal: configScrollbarOpts.horizontal, horizontal: configScrollbarOpts.horizontal,
className: ClassNames.SCROLLABLE_ELEMENT + ' ' + this.configuration.editor.theme, className: ClassNames.SCROLLABLE_ELEMENT + ' ' + this.configuration.editor.viewInfo.theme,
useShadows: false, useShadows: false,
lazyRender: true, lazyRender: true,
saveLastScrollTimeOnClassName: ClassNames.VIEW_LINE saveLastScrollTimeOnClassName: ClassNames.VIEW_LINE
...@@ -63,7 +63,7 @@ export class ScrollManager implements IDisposable { ...@@ -63,7 +63,7 @@ export class ScrollManager implements IDisposable {
})); }));
this.toDispose.push(this.configuration.onDidChange((e:IConfigurationChangedEvent) => { this.toDispose.push(this.configuration.onDidChange((e:IConfigurationChangedEvent) => {
this.scrollbar.updateClassName(this.configuration.editor.theme); this.scrollbar.updateClassName(ClassNames.SCROLLABLE_ELEMENT + ' ' + this.configuration.editor.viewInfo.theme);
if (e.viewInfo.scrollbar) { if (e.viewInfo.scrollbar) {
let newOpts:ScrollableElementChangeOptions = { let newOpts:ScrollableElementChangeOptions = {
canUseTranslate3d: true, canUseTranslate3d: true,
......
...@@ -23,7 +23,6 @@ export class ViewLine implements IVisibleLineData { ...@@ -23,7 +23,6 @@ export class ViewLine implements IVisibleLineData {
private _spaceWidth: number; private _spaceWidth: number;
private _lineHeight: number; private _lineHeight: number;
private _stopRenderingLineAfter: number; private _stopRenderingLineAfter: number;
protected _fontLigatures: boolean;
private _domNode: FastDomNode; private _domNode: FastDomNode;
...@@ -43,7 +42,6 @@ export class ViewLine implements IVisibleLineData { ...@@ -43,7 +42,6 @@ export class ViewLine implements IVisibleLineData {
this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth;
this._lineHeight = this._context.configuration.editor.lineHeight; this._lineHeight = this._context.configuration.editor.lineHeight;
this._stopRenderingLineAfter = this._context.configuration.editor.viewInfo.stopRenderingLineAfter; this._stopRenderingLineAfter = this._context.configuration.editor.viewInfo.stopRenderingLineAfter;
this._fontLigatures = this._context.configuration.editor.fontLigatures;
this._domNode = null; this._domNode = null;
this._isInvalid = true; this._isInvalid = true;
...@@ -99,9 +97,6 @@ export class ViewLine implements IVisibleLineData { ...@@ -99,9 +97,6 @@ export class ViewLine implements IVisibleLineData {
if (e.viewInfo.stopRenderingLineAfter) { if (e.viewInfo.stopRenderingLineAfter) {
this._stopRenderingLineAfter = this._context.configuration.editor.viewInfo.stopRenderingLineAfter; this._stopRenderingLineAfter = this._context.configuration.editor.viewInfo.stopRenderingLineAfter;
} }
if (e.fontLigatures) {
this._fontLigatures = this._context.configuration.editor.fontLigatures;
}
this._isInvalid = true; this._isInvalid = true;
} }
...@@ -312,18 +307,6 @@ class WebKitViewLine extends ViewLine { ...@@ -312,18 +307,6 @@ class WebKitViewLine extends ViewLine {
protected _readVisibleRangesForRange(startColumn:number, endColumn:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] { protected _readVisibleRangesForRange(startColumn:number, endColumn:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
let output = super._readVisibleRangesForRange(startColumn, endColumn, clientRectDeltaLeft, endNode); let output = super._readVisibleRangesForRange(startColumn, endColumn, clientRectDeltaLeft, endNode);
if (this._fontLigatures && output.length === 1 && endColumn > 1 && endColumn === this._charOffsetInPart.length) {
let lastSpanBoundingClientRect = (<HTMLElement>this._getReadingTarget().lastChild).getBoundingClientRect();
let lastSpanBoundingClientRectRight = lastSpanBoundingClientRect.right - clientRectDeltaLeft;
if (startColumn === endColumn) {
output[0].left = lastSpanBoundingClientRectRight;
output[0].width = 0;
} else {
output[0].width = lastSpanBoundingClientRectRight - output[0].left;
}
return output;
}
if (!output || output.length === 0 || startColumn === endColumn || (startColumn === 1 && endColumn === this._charOffsetInPart.length)) { if (!output || output.length === 0 || startColumn === endColumn || (startColumn === 1 && endColumn === this._charOffsetInPart.length)) {
return output; return output;
} }
......
...@@ -42,7 +42,7 @@ export class DecorationsOverviewRuler extends ViewPart { ...@@ -42,7 +42,7 @@ export class DecorationsOverviewRuler extends ViewPart {
getVerticalOffsetForLine getVerticalOffsetForLine
); );
this._overviewRuler.setLanesCount(this._context.configuration.editor.viewInfo.overviewRulerLanes, false); this._overviewRuler.setLanesCount(this._context.configuration.editor.viewInfo.overviewRulerLanes, false);
let theme = this._context.configuration.editor.theme; let theme = this._context.configuration.editor.viewInfo.theme;
this._overviewRuler.setUseDarkColor(!themes.isLightTheme(theme), false); this._overviewRuler.setUseDarkColor(!themes.isLightTheme(theme), false);
this._shouldUpdateDecorations = true; this._shouldUpdateDecorations = true;
...@@ -91,8 +91,8 @@ export class DecorationsOverviewRuler extends ViewPart { ...@@ -91,8 +91,8 @@ export class DecorationsOverviewRuler extends ViewPart {
shouldRender = true; shouldRender = true;
} }
if (e.theme) { if (e.viewInfo.theme) {
let theme = this._context.configuration.editor.theme; let theme = this._context.configuration.editor.viewInfo.theme;
this._overviewRuler.setUseDarkColor(!themes.isLightTheme(theme), false); this._overviewRuler.setUseDarkColor(!themes.isLightTheme(theme), false);
shouldRender = true; shouldRender = true;
} }
......
...@@ -91,9 +91,9 @@ export class CodeEditorWidget extends CommonCodeEditor implements editorBrowser. ...@@ -91,9 +91,9 @@ export class CodeEditorWidget extends CommonCodeEditor implements editorBrowser.
} }
public updateOptions(newOptions:editorCommon.IEditorOptions): void { public updateOptions(newOptions:editorCommon.IEditorOptions): void {
let oldTheme = this._configuration.editor.theme; let oldTheme = this._configuration.editor.viewInfo.theme;
super.updateOptions(newOptions); super.updateOptions(newOptions);
let newTheme = this._configuration.editor.theme; let newTheme = this._configuration.editor.viewInfo.theme;
if (oldTheme !== newTheme) { if (oldTheme !== newTheme) {
this.render(); this.render();
......
...@@ -1718,7 +1718,7 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor ...@@ -1718,7 +1718,7 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
class InlineViewZonesComputer extends ViewZonesComputer { class InlineViewZonesComputer extends ViewZonesComputer {
private originalModel:editorCommon.IModel; private originalModel:editorCommon.IModel;
private modifiedEditorConfiguration:editorCommon.IInternalEditorOptions; private modifiedEditorConfiguration:editorCommon.InternalEditorOptions;
private modifiedEditorTabSize:number; private modifiedEditorTabSize:number;
constructor(lineChanges:editorCommon.ILineChange[], originalForeignVZ:editorCommon.IEditorWhitespace[], modifiedForeignVZ:editorCommon.IEditorWhitespace[], originalEditor:editorBrowser.ICodeEditor, modifiedEditor:editorBrowser.ICodeEditor) { constructor(lineChanges:editorCommon.ILineChange[], originalForeignVZ:editorCommon.IEditorWhitespace[], modifiedForeignVZ:editorCommon.IEditorWhitespace[], originalEditor:editorBrowser.ICodeEditor, modifiedEditor:editorBrowser.ICodeEditor) {
...@@ -1773,7 +1773,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { ...@@ -1773,7 +1773,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
}; };
} }
private renderOriginalLine(count:number, originalModel:editorCommon.IModel, config:editorCommon.IInternalEditorOptions, tabSize:number, lineNumber:number, decorations:editorCommon.IModelDecoration[]): string[] { private renderOriginalLine(count:number, originalModel:editorCommon.IModel, config:editorCommon.InternalEditorOptions, tabSize:number, lineNumber:number, decorations:editorCommon.IModelDecoration[]): string[] {
let lineContent = originalModel.getLineContent(lineNumber); let lineContent = originalModel.getLineContent(lineNumber);
let lineTokens = new ViewLineTokens([new ViewLineToken(0, '')], 0, lineContent.length); let lineTokens = new ViewLineTokens([new ViewLineToken(0, '')], 0, lineContent.length);
......
...@@ -181,7 +181,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr ...@@ -181,7 +181,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr
} }
} }
public getConfiguration(): editorCommon.IInternalEditorOptions { public getConfiguration(): editorCommon.InternalEditorOptions {
return this._configuration.editorClone; return this._configuration.editorClone;
} }
......
...@@ -11,7 +11,7 @@ import * as objects from 'vs/base/common/objects'; ...@@ -11,7 +11,7 @@ import * as objects from 'vs/base/common/objects';
import * as platform from 'vs/base/common/platform'; import * as platform from 'vs/base/common/platform';
import {Extensions, IConfigurationRegistry, IConfigurationNode} from 'vs/platform/configuration/common/configurationRegistry'; import {Extensions, IConfigurationRegistry, IConfigurationNode} from 'vs/platform/configuration/common/configurationRegistry';
import {Registry} from 'vs/platform/platform'; import {Registry} from 'vs/platform/platform';
import {DefaultConfig, DEFAULT_INDENTATION, GOLDEN_LINE_HEIGHT_RATIO} from 'vs/editor/common/config/defaultConfig'; import {DefaultConfig, DEFAULT_INDENTATION, DEFAULT_TRIM_AUTO_WHITESPACE, GOLDEN_LINE_HEIGHT_RATIO} from 'vs/editor/common/config/defaultConfig';
import * as editorCommon from 'vs/editor/common/editorCommon'; import * as editorCommon from 'vs/editor/common/editorCommon';
import {EditorLayoutProvider} from 'vs/editor/common/viewLayout/editorLayoutProvider'; import {EditorLayoutProvider} from 'vs/editor/common/viewLayout/editorLayoutProvider';
import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElementOptions'; import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElementOptions';
...@@ -62,46 +62,6 @@ export class ConfigurationWithDefaults { ...@@ -62,46 +62,6 @@ export class ConfigurationWithDefaults {
} }
} }
export class InternalEditorOptions implements editorCommon.IInternalEditorOptions {
_internalEditorOptionsBrand: void;
wordSeparators: string;
theme:string;
readOnly:boolean;
fontLigatures:boolean;
tabFocusMode:boolean;
stopLineTokenizationAfter:number;
longLineBoundary:number;
autoClosingBrackets:boolean;
useTabStops: boolean;
trimAutoWhitespace: boolean;
layoutInfo: editorCommon.EditorLayoutInfo;
fontInfo: editorCommon.FontInfo;
viewInfo: editorCommon.InternalEditorViewOptions;
wrappingInfo: editorCommon.EditorWrappingInfo;
contribInfo: editorCommon.EditorContribOptions;
lineHeight:number;
constructor(input:editorCommon.IInternalEditorOptions) {
this.wordSeparators = String(input.wordSeparators);
this.theme = String(input.theme);
this.readOnly = Boolean(input.readOnly);
this.fontLigatures = Boolean(input.fontLigatures);
this.tabFocusMode = Boolean(input.tabFocusMode);
this.stopLineTokenizationAfter = Number(input.stopLineTokenizationAfter)|0;
this.longLineBoundary = Number(input.longLineBoundary)|0;
this.autoClosingBrackets = Boolean(input.autoClosingBrackets);
this.useTabStops = Boolean(input.useTabStops);
this.trimAutoWhitespace = Boolean(input.trimAutoWhitespace);
this.layoutInfo = input.layoutInfo.clone();
this.fontInfo = input.fontInfo.clone();
this.viewInfo = input.viewInfo.clone();
this.wrappingInfo = input.wrappingInfo.clone();
this.contribInfo = input.contribInfo.clone();
this.lineHeight = Number(input.lineHeight)|0;
}
}
class InternalEditorOptionsHelper { class InternalEditorOptionsHelper {
constructor() { constructor() {
...@@ -114,7 +74,7 @@ class InternalEditorOptionsHelper { ...@@ -114,7 +74,7 @@ class InternalEditorOptionsHelper {
editorClassName:string, editorClassName:string,
isDominatedByLongLines:boolean, isDominatedByLongLines:boolean,
lineCount: number lineCount: number
): editorCommon.IInternalEditorOptions { ): editorCommon.InternalEditorOptions {
let wrappingColumn = toInteger(opts.wrappingColumn, -1); let wrappingColumn = toInteger(opts.wrappingColumn, -1);
...@@ -203,6 +163,7 @@ class InternalEditorOptionsHelper { ...@@ -203,6 +163,7 @@ class InternalEditorOptionsHelper {
} }
let viewInfo = new editorCommon.InternalEditorViewOptions({ let viewInfo = new editorCommon.InternalEditorViewOptions({
theme: opts.theme,
experimentalScreenReader: toBoolean(opts.experimentalScreenReader), experimentalScreenReader: toBoolean(opts.experimentalScreenReader),
rulers: toSortedIntegerArray(opts.rulers), rulers: toSortedIntegerArray(opts.rulers),
ariaLabel: String(opts.ariaLabel), ariaLabel: String(opts.ariaLabel),
...@@ -239,28 +200,21 @@ class InternalEditorOptionsHelper { ...@@ -239,28 +200,21 @@ class InternalEditorOptionsHelper {
folding: toBoolean(opts.folding), folding: toBoolean(opts.folding),
}); });
return { return new editorCommon.InternalEditorOptions({
// ---- Options that are transparent - get no massaging
theme: opts.theme,
readOnly: readOnly,
wordSeparators: String(opts.wordSeparators),
fontLigatures: toBoolean(opts.fontLigatures),
tabFocusMode: tabFocusMode,
stopLineTokenizationAfter: stopLineTokenizationAfter, stopLineTokenizationAfter: stopLineTokenizationAfter,
longLineBoundary: toInteger(opts.longLineBoundary), longLineBoundary: toInteger(opts.longLineBoundary),
lineHeight: fontInfo.lineHeight, // todo -> duplicated in styling
readOnly: readOnly,
wordSeparators: String(opts.wordSeparators),
autoClosingBrackets: toBoolean(opts.autoClosingBrackets), autoClosingBrackets: toBoolean(opts.autoClosingBrackets),
useTabStops: toBoolean(opts.useTabStops), useTabStops: toBoolean(opts.useTabStops),
trimAutoWhitespace: toBoolean(opts.trimAutoWhitespace), tabFocusMode: tabFocusMode,
layoutInfo: layoutInfo, layoutInfo: layoutInfo,
fontInfo: fontInfo, fontInfo: fontInfo,
viewInfo: viewInfo, viewInfo: viewInfo,
wrappingInfo: wrappingInfo, wrappingInfo: wrappingInfo,
contribInfo: contribInfo, contribInfo: contribInfo,
});
lineHeight: fontInfo.lineHeight, // todo -> duplicated in styling
};
} }
private static _sanitizeScrollbarOpts(raw:editorCommon.IEditorScrollbarOptions, mouseWheelScrollSensitivity:number): editorCommon.InternalEditorScrollbarOptions { private static _sanitizeScrollbarOpts(raw:editorCommon.IEditorScrollbarOptions, mouseWheelScrollSensitivity:number): editorCommon.InternalEditorScrollbarOptions {
...@@ -298,30 +252,6 @@ class InternalEditorOptionsHelper { ...@@ -298,30 +252,6 @@ class InternalEditorOptionsHelper {
mouseWheelScrollSensitivity: mouseWheelScrollSensitivity mouseWheelScrollSensitivity: mouseWheelScrollSensitivity
}); });
} }
public static createConfigurationChangedEvent(prevOpts:InternalEditorOptions, newOpts:InternalEditorOptions): editorCommon.IConfigurationChangedEvent {
return {
wordSeparators: (prevOpts.wordSeparators !== newOpts.wordSeparators),
theme: (prevOpts.theme !== newOpts.theme),
readOnly: (prevOpts.readOnly !== newOpts.readOnly),
fontLigatures: (prevOpts.fontLigatures !== newOpts.fontLigatures),
tabFocusMode: (prevOpts.tabFocusMode !== newOpts.tabFocusMode),
stopLineTokenizationAfter: (prevOpts.stopLineTokenizationAfter !== newOpts.stopLineTokenizationAfter),
longLineBoundary: (prevOpts.longLineBoundary !== newOpts.longLineBoundary),
autoClosingBrackets: (prevOpts.autoClosingBrackets !== newOpts.autoClosingBrackets),
useTabStops: (prevOpts.useTabStops !== newOpts.useTabStops),
trimAutoWhitespace: (prevOpts.trimAutoWhitespace !== newOpts.trimAutoWhitespace),
layoutInfo: (!prevOpts.layoutInfo.equals(newOpts.layoutInfo)),
fontInfo: (!prevOpts.fontInfo.equals(newOpts.fontInfo)),
viewInfo: prevOpts.viewInfo.createChangeEvent(newOpts.viewInfo),
wrappingInfo: (!prevOpts.wrappingInfo.equals(newOpts.wrappingInfo)),
contribInfo: (!prevOpts.contribInfo.equals(newOpts.contribInfo)),
lineHeight: (prevOpts.lineHeight !== newOpts.lineHeight),
};
}
} }
function toBoolean(value:any): boolean { function toBoolean(value:any): boolean {
...@@ -412,8 +342,8 @@ export interface IElementSizeObserver { ...@@ -412,8 +342,8 @@ export interface IElementSizeObserver {
export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration {
public editor:InternalEditorOptions; public editor:editorCommon.InternalEditorOptions;
public editorClone:InternalEditorOptions; public editorClone:editorCommon.InternalEditorOptions;
protected _configWithDefaults:ConfigurationWithDefaults; protected _configWithDefaults:ConfigurationWithDefaults;
protected _elementSizeObserver: IElementSizeObserver; protected _elementSizeObserver: IElementSizeObserver;
...@@ -429,9 +359,8 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -429,9 +359,8 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
this._elementSizeObserver = elementSizeObserver; this._elementSizeObserver = elementSizeObserver;
this._isDominatedByLongLines = false; this._isDominatedByLongLines = false;
this._lineCount = 1; this._lineCount = 1;
this.editor = this._computeInternalOptions(); this.editor = this._computeInternalOptions();
this.editorClone = new InternalEditorOptions(this.editor); this.editorClone = this.editor.clone();
} }
public dispose(): void { public dispose(): void {
...@@ -439,41 +368,25 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -439,41 +368,25 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
} }
protected _recomputeOptions(): void { protected _recomputeOptions(): void {
let oldOpts = this.editor; this._setOptions(this._computeInternalOptions());
this.editor = this._computeInternalOptions(); }
this.editorClone = new InternalEditorOptions(this.editor);
let changeEvent = InternalEditorOptionsHelper.createConfigurationChangedEvent(oldOpts, this.editor);
let hasChanged = false;
let keys = Object.keys(changeEvent);
for (let i = 0, len = keys.length; i < len; i++) {
let key = keys[i];
if (changeEvent[key] === true) {
hasChanged = true;
break;
}
}
keys = Object.keys(changeEvent.viewInfo); private _setOptions(newOptions:editorCommon.InternalEditorOptions): void {
for (let i = 0, len = keys.length; i < len; i++) { if (this.editor && this.editor.equals(newOptions)) {
let key = keys[i]; return;
if (changeEvent[key] === true) {
hasChanged = true;
break;
}
} }
if (hasChanged) { let changeEvent = this.editor.createChangeEvent(newOptions);
this._onDidChange.fire(changeEvent); this.editor = newOptions;
} this.editorClone = this.editor.clone();
this._onDidChange.fire(changeEvent);
} }
public getRawOptions(): editorCommon.IEditorOptions { public getRawOptions(): editorCommon.IEditorOptions {
return this._configWithDefaults.getEditorOptions(); return this._configWithDefaults.getEditorOptions();
} }
private _computeInternalOptions(): InternalEditorOptions { private _computeInternalOptions(): editorCommon.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));
...@@ -485,7 +398,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -485,7 +398,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize); lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize);
} }
let result = InternalEditorOptionsHelper.createInternalEditorOptions( return InternalEditorOptionsHelper.createInternalEditorOptions(
this.getOuterWidth(), this.getOuterWidth(),
this.getOuterHeight(), this.getOuterHeight(),
opts, opts,
...@@ -498,8 +411,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed ...@@ -498,8 +411,6 @@ 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 {
...@@ -764,7 +675,7 @@ let editorConfiguration:IConfigurationNode = { ...@@ -764,7 +675,7 @@ let editorConfiguration:IConfigurationNode = {
}, },
'editor.trimAutoWhitespace' : { 'editor.trimAutoWhitespace' : {
'type': 'boolean', 'type': 'boolean',
'default': DefaultConfig.editor.trimAutoWhitespace, 'default': DEFAULT_TRIM_AUTO_WHITESPACE,
'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace") 'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace")
}, },
'editor.dismissPeekOnEsc' : { 'editor.dismissPeekOnEsc' : {
......
...@@ -18,6 +18,7 @@ export const DEFAULT_INDENTATION = { ...@@ -18,6 +18,7 @@ export const DEFAULT_INDENTATION = {
insertSpaces: true, insertSpaces: true,
detectIndentation: true detectIndentation: true
}; };
export const DEFAULT_TRIM_AUTO_WHITESPACE = true;
const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace'; const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace'; const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
...@@ -90,7 +91,6 @@ class ConfigClass implements IConfiguration { ...@@ -90,7 +91,6 @@ class ConfigClass implements IConfiguration {
renderWhitespace: false, renderWhitespace: false,
indentGuides: false, indentGuides: false,
useTabStops: true, useTabStops: true,
trimAutoWhitespace: true,
fontFamily: ( fontFamily: (
platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY) platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY)
......
...@@ -400,7 +400,6 @@ export interface IEditorOptions { ...@@ -400,7 +400,6 @@ export interface IEditorOptions {
*/ */
wordWrapBreakObtrusiveCharacters?: string; wordWrapBreakObtrusiveCharacters?: string;
// autoSize?:boolean;
/** /**
* Control what pressing Tab does. * Control what pressing Tab does.
* If it is false, pressing Tab or Shift-Tab will be handled by the editor. * If it is false, pressing Tab or Shift-Tab will be handled by the editor.
...@@ -511,10 +510,6 @@ export interface IEditorOptions { ...@@ -511,10 +510,6 @@ export interface IEditorOptions {
* Inserting and deleting whitespace follows tab stops. * Inserting and deleting whitespace follows tab stops.
*/ */
useTabStops?: boolean; useTabStops?: boolean;
/**
* Remove trailing auto inserted whitespace.
*/
trimAutoWhitespace?: boolean;
/** /**
* The font family * The font family
*/ */
...@@ -666,6 +661,7 @@ export class EditorWrappingInfo { ...@@ -666,6 +661,7 @@ export class EditorWrappingInfo {
export class InternalEditorViewOptions { export class InternalEditorViewOptions {
_internalEditorViewOptionsBrand: void; _internalEditorViewOptionsBrand: void;
theme:string;
experimentalScreenReader: boolean; experimentalScreenReader: boolean;
rulers: number[]; rulers: number[];
ariaLabel: string; ariaLabel: string;
...@@ -686,6 +682,7 @@ export class InternalEditorViewOptions { ...@@ -686,6 +682,7 @@ export class InternalEditorViewOptions {
scrollbar:InternalEditorScrollbarOptions; scrollbar:InternalEditorScrollbarOptions;
constructor(source:{ constructor(source:{
theme:string;
experimentalScreenReader: boolean; experimentalScreenReader: boolean;
rulers: number[]; rulers: number[];
ariaLabel: string; ariaLabel: string;
...@@ -705,6 +702,7 @@ export class InternalEditorViewOptions { ...@@ -705,6 +702,7 @@ export class InternalEditorViewOptions {
indentGuides: boolean; indentGuides: boolean;
scrollbar:InternalEditorScrollbarOptions; scrollbar:InternalEditorScrollbarOptions;
}) { }) {
this.theme = String(source.theme);
this.experimentalScreenReader = Boolean(source.experimentalScreenReader); this.experimentalScreenReader = Boolean(source.experimentalScreenReader);
this.rulers = InternalEditorViewOptions._toSortedIntegerArray(source.rulers); this.rulers = InternalEditorViewOptions._toSortedIntegerArray(source.rulers);
this.ariaLabel = String(source.ariaLabel); this.ariaLabel = String(source.ariaLabel);
...@@ -755,7 +753,8 @@ export class InternalEditorViewOptions { ...@@ -755,7 +753,8 @@ export class InternalEditorViewOptions {
public equals(other:InternalEditorViewOptions): boolean { public equals(other:InternalEditorViewOptions): boolean {
return ( return (
this.experimentalScreenReader === other.experimentalScreenReader this.theme === other.theme
&& this.experimentalScreenReader === other.experimentalScreenReader
&& InternalEditorViewOptions._numberArraysEqual(this.rulers, other.rulers) && InternalEditorViewOptions._numberArraysEqual(this.rulers, other.rulers)
&& this.ariaLabel === other.ariaLabel && this.ariaLabel === other.ariaLabel
&& this.lineNumbers === other.lineNumbers && this.lineNumbers === other.lineNumbers
...@@ -778,6 +777,7 @@ export class InternalEditorViewOptions { ...@@ -778,6 +777,7 @@ export class InternalEditorViewOptions {
public createChangeEvent(newOpts:InternalEditorViewOptions): IViewConfigurationChangedEvent { public createChangeEvent(newOpts:InternalEditorViewOptions): IViewConfigurationChangedEvent {
return { return {
theme: this.theme !== newOpts.theme,
experimentalScreenReader: this.experimentalScreenReader !== newOpts.experimentalScreenReader, experimentalScreenReader: this.experimentalScreenReader !== newOpts.experimentalScreenReader,
rulers: (!InternalEditorViewOptions._numberArraysEqual(this.rulers, newOpts.rulers)), rulers: (!InternalEditorViewOptions._numberArraysEqual(this.rulers, newOpts.rulers)),
ariaLabel: this.ariaLabel !== newOpts.ariaLabel, ariaLabel: this.ariaLabel !== newOpts.ariaLabel,
...@@ -805,6 +805,7 @@ export class InternalEditorViewOptions { ...@@ -805,6 +805,7 @@ export class InternalEditorViewOptions {
} }
export interface IViewConfigurationChangedEvent { export interface IViewConfigurationChangedEvent {
theme: boolean;
experimentalScreenReader: boolean; experimentalScreenReader: boolean;
rulers: boolean; rulers: boolean;
ariaLabel: boolean; ariaLabel: boolean;
...@@ -896,64 +897,114 @@ export class EditorContribOptions { ...@@ -896,64 +897,114 @@ export class EditorContribOptions {
/** /**
* Internal configuration options (transformed or computed) for the editor. * Internal configuration options (transformed or computed) for the editor.
*/ */
export interface IInternalEditorOptions { export class InternalEditorOptions {
readOnly:boolean; _internalEditorOptionsBrand: void;
stopLineTokenizationAfter:number; // todo: move to model opts
longLineBoundary:number; // todo: move to model opts
lineHeight:number; // todo: move to fontInfo
readOnly:boolean;
// ---- cursor options // ---- cursor options
wordSeparators: string; wordSeparators: string;
autoClosingBrackets:boolean; autoClosingBrackets:boolean;
useTabStops: boolean; useTabStops: boolean;
tabFocusMode:boolean; tabFocusMode:boolean;
// ---- grouped options
// ---- model options
trimAutoWhitespace: boolean;
stopLineTokenizationAfter:number;
longLineBoundary:number;
// ---- Options that are transparent - get no massaging
theme:string; // todo: move to viewInfo
fontLigatures:boolean; // todo: move to fontInfo
// ---- Options that are computed
layoutInfo: EditorLayoutInfo; layoutInfo: EditorLayoutInfo;
fontInfo: FontInfo; fontInfo: FontInfo;
viewInfo: InternalEditorViewOptions; viewInfo: InternalEditorViewOptions;
wrappingInfo: EditorWrappingInfo; wrappingInfo: EditorWrappingInfo;
contribInfo: EditorContribOptions; contribInfo: EditorContribOptions;
/** constructor(source: {
* Computed line height (deduced from theme and CSS) in px. stopLineTokenizationAfter:number;
*/ longLineBoundary:number;
lineHeight:number; // todo: move to fontInfo lineHeight:number;
readOnly:boolean;
wordSeparators: string;
autoClosingBrackets:boolean;
useTabStops: boolean;
tabFocusMode:boolean;
layoutInfo: EditorLayoutInfo;
fontInfo: FontInfo;
viewInfo: InternalEditorViewOptions;
wrappingInfo: EditorWrappingInfo;
contribInfo: EditorContribOptions;
}) {
this.stopLineTokenizationAfter = source.stopLineTokenizationAfter|0;
this.longLineBoundary = source.longLineBoundary|0;
this.lineHeight = source.lineHeight|0;
this.readOnly = Boolean(source.readOnly);
this.wordSeparators = String(source.wordSeparators);
this.autoClosingBrackets = Boolean(source.autoClosingBrackets);
this.useTabStops = Boolean(source.useTabStops);
this.tabFocusMode = Boolean(source.tabFocusMode);
this.layoutInfo = source.layoutInfo.clone();
this.fontInfo = source.fontInfo.clone();
this.viewInfo = source.viewInfo.clone();
this.wrappingInfo = source.wrappingInfo.clone();
this.contribInfo = source.contribInfo.clone();
}
public equals(other:InternalEditorOptions): boolean {
return (
this.stopLineTokenizationAfter === other.stopLineTokenizationAfter
&& this.longLineBoundary === other.longLineBoundary
&& this.lineHeight === other.lineHeight
&& this.readOnly === other.readOnly
&& this.wordSeparators === other.wordSeparators
&& this.autoClosingBrackets === other.autoClosingBrackets
&& this.useTabStops === other.useTabStops
&& this.tabFocusMode === other.tabFocusMode
&& this.layoutInfo.equals(other.layoutInfo)
&& this.fontInfo.equals(other.fontInfo)
&& this.viewInfo.equals(other.viewInfo)
&& this.wrappingInfo.equals(other.wrappingInfo)
&& this.contribInfo.equals(other.contribInfo)
);
}
public createChangeEvent(newOpts:InternalEditorOptions): IConfigurationChangedEvent {
return {
stopLineTokenizationAfter: (this.stopLineTokenizationAfter !== newOpts.stopLineTokenizationAfter),
longLineBoundary: (this.longLineBoundary !== newOpts.longLineBoundary),
lineHeight: (this.lineHeight !== newOpts.lineHeight),
readOnly: (this.readOnly !== newOpts.readOnly),
wordSeparators: (this.wordSeparators !== newOpts.wordSeparators),
autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets),
useTabStops: (this.useTabStops !== newOpts.useTabStops),
tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode),
layoutInfo: (!this.layoutInfo.equals(newOpts.layoutInfo)),
fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)),
viewInfo: this.viewInfo.createChangeEvent(newOpts.viewInfo),
wrappingInfo: (!this.wrappingInfo.equals(newOpts.wrappingInfo)),
contribInfo: (!this.contribInfo.equals(newOpts.contribInfo)),
};
}
public clone(): InternalEditorOptions {
return new InternalEditorOptions(this);
}
} }
/** /**
* An event describing that the configuration of the editor has changed. * An event describing that the configuration of the editor has changed.
*/ */
export interface IConfigurationChangedEvent { export interface IConfigurationChangedEvent {
wordSeparators: boolean;
// ---- Options that are transparent - get no massaging
theme: boolean;
readOnly: boolean;
fontLigatures: boolean;
tabFocusMode: boolean;
stopLineTokenizationAfter: boolean; stopLineTokenizationAfter: boolean;
longLineBoundary: boolean; longLineBoundary: boolean;
lineHeight: boolean;
// ---- Options that are transparent - get no massaging readOnly: boolean;
wordSeparators: boolean;
autoClosingBrackets: boolean; autoClosingBrackets: boolean;
useTabStops: boolean; useTabStops: boolean;
trimAutoWhitespace: boolean; tabFocusMode: boolean;
// ---- Options that are computed
layoutInfo: boolean; layoutInfo: boolean;
fontInfo: boolean; fontInfo: boolean;
viewInfo: IViewConfigurationChangedEvent; viewInfo: IViewConfigurationChangedEvent;
wrappingInfo: boolean; wrappingInfo: boolean;
contribInfo: boolean; contribInfo: boolean;
lineHeight: boolean;
} }
/** /**
...@@ -2789,7 +2840,7 @@ export class FontInfo extends BareFontInfo { ...@@ -2789,7 +2840,7 @@ export class FontInfo extends BareFontInfo {
export interface IConfiguration { export interface IConfiguration {
onDidChange: Event<IConfigurationChangedEvent>; onDidChange: Event<IConfigurationChangedEvent>;
editor:IInternalEditorOptions; editor:InternalEditorOptions;
setLineCount(lineCount:number): void; setLineCount(lineCount:number): void;
} }
...@@ -3314,7 +3365,7 @@ export interface ICommonCodeEditor extends IEditor { ...@@ -3314,7 +3365,7 @@ export interface ICommonCodeEditor extends IEditor {
/** /**
* Returns the current editor's configuration * Returns the current editor's configuration
*/ */
getConfiguration(): IInternalEditorOptions; getConfiguration(): InternalEditorOptions;
/** /**
* Returns the 'raw' editor's configuration, as it was applied over the defaults, but without any computed members. * Returns the 'raw' editor's configuration, as it was applied over the defaults, but without any computed members.
......
...@@ -11,7 +11,7 @@ import {Range} from 'vs/editor/common/core/range'; ...@@ -11,7 +11,7 @@ import {Range} from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon'; import * as editorCommon from 'vs/editor/common/editorCommon';
import {ModelLine} from 'vs/editor/common/model/modelLine'; import {ModelLine} from 'vs/editor/common/model/modelLine';
import {guessIndentation} from 'vs/editor/common/model/indentationGuesser'; import {guessIndentation} from 'vs/editor/common/model/indentationGuesser';
import {DEFAULT_INDENTATION, DefaultConfig} from 'vs/editor/common/config/defaultConfig'; import {DEFAULT_INDENTATION, DEFAULT_TRIM_AUTO_WHITESPACE} from 'vs/editor/common/config/defaultConfig';
var LIMIT_FIND_COUNT = 999; var LIMIT_FIND_COUNT = 999;
...@@ -21,7 +21,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo ...@@ -21,7 +21,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
tabSize: DEFAULT_INDENTATION.tabSize, tabSize: DEFAULT_INDENTATION.tabSize,
insertSpaces: DEFAULT_INDENTATION.insertSpaces, insertSpaces: DEFAULT_INDENTATION.insertSpaces,
detectIndentation: false, detectIndentation: false,
trimAutoWhitespace: DefaultConfig.editor.trimAutoWhitespace, trimAutoWhitespace: DEFAULT_TRIM_AUTO_WHITESPACE,
defaultEOL: editorCommon.DefaultEndOfLine.LF defaultEOL: editorCommon.DefaultEndOfLine.LF
}; };
......
...@@ -26,7 +26,7 @@ import {IModelService} from 'vs/editor/common/services/modelService'; ...@@ -26,7 +26,7 @@ import {IModelService} from 'vs/editor/common/services/modelService';
import {IResourceService} from 'vs/editor/common/services/resourceService'; import {IResourceService} from 'vs/editor/common/services/resourceService';
import * as platform from 'vs/base/common/platform'; import * as platform from 'vs/base/common/platform';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {DEFAULT_INDENTATION, DefaultConfig} from 'vs/editor/common/config/defaultConfig'; import {DEFAULT_INDENTATION, DEFAULT_TRIM_AUTO_WHITESPACE} from 'vs/editor/common/config/defaultConfig';
import {IMessageService} from 'vs/platform/message/common/message'; import {IMessageService} from 'vs/platform/message/common/message';
export interface IRawModelData { export interface IRawModelData {
...@@ -221,7 +221,7 @@ export class ModelServiceImpl implements IModelService { ...@@ -221,7 +221,7 @@ export class ModelServiceImpl implements IModelService {
insertSpaces: DEFAULT_INDENTATION.insertSpaces, insertSpaces: DEFAULT_INDENTATION.insertSpaces,
detectIndentation: DEFAULT_INDENTATION.detectIndentation, detectIndentation: DEFAULT_INDENTATION.detectIndentation,
defaultEOL: (platform.isLinux || platform.isMacintosh) ? editorCommon.DefaultEndOfLine.LF : editorCommon.DefaultEndOfLine.CRLF, defaultEOL: (platform.isLinux || platform.isMacintosh) ? editorCommon.DefaultEndOfLine.LF : editorCommon.DefaultEndOfLine.CRLF,
trimAutoWhitespace: DefaultConfig.editor.trimAutoWhitespace trimAutoWhitespace: DEFAULT_TRIM_AUTO_WHITESPACE
}; };
this._threadService = threadService; this._threadService = threadService;
this._markerService = markerService; this._markerService = markerService;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册