Fixes #16573: Ensure textEditor.options always contains all properties

This commit is contained in:
Alex Dima
2016-12-07 14:14:50 +01:00
parent 887f9c180b
commit 19291ef2c1
5 changed files with 544 additions and 36 deletions

View File

@@ -17,8 +17,8 @@ import { Selection } from 'vs/editor/common/core/selection';
import { EndOfLine, TextEditorLineNumbersStyle } from 'vs/workbench/api/node/extHostTypes';
export interface ITextEditorConfigurationUpdate {
tabSize?: number | string;
insertSpaces?: boolean | string;
tabSize?: number | 'auto';
insertSpaces?: boolean | 'auto';
cursorStyle?: EditorCommon.TextEditorCursorStyle;
lineNumbers?: TextEditorLineNumbersStyle;
}
@@ -209,18 +209,12 @@ export class MainThreadTextEditor {
let insertSpaces = creationOpts.insertSpaces;
let tabSize = creationOpts.tabSize;
if (newConfiguration.insertSpaces !== 'auto') {
if (typeof newConfiguration.insertSpaces !== 'undefined') {
insertSpaces = (newConfiguration.insertSpaces === 'false' ? false : Boolean(newConfiguration.insertSpaces));
}
if (newConfiguration.insertSpaces !== 'auto' && typeof newConfiguration.insertSpaces !== 'undefined') {
insertSpaces = newConfiguration.insertSpaces;
}
if (newConfiguration.tabSize !== 'auto') {
if (typeof newConfiguration.tabSize !== 'undefined') {
let parsedTabSize = parseInt(<string>newConfiguration.tabSize, 10);
if (!isNaN(parsedTabSize)) {
tabSize = parsedTabSize;
}
}
if (newConfiguration.tabSize !== 'auto' && typeof newConfiguration.tabSize !== 'undefined') {
tabSize = newConfiguration.tabSize;
}
this._model.detectIndentation(insertSpaces, tabSize);
@@ -229,13 +223,10 @@ export class MainThreadTextEditor {
let newOpts: EditorCommon.ITextModelUpdateOptions = {};
if (typeof newConfiguration.insertSpaces !== 'undefined') {
newOpts.insertSpaces = (newConfiguration.insertSpaces === 'false' ? false : Boolean(newConfiguration.insertSpaces));
newOpts.insertSpaces = newConfiguration.insertSpaces;
}
if (typeof newConfiguration.tabSize !== 'undefined') {
let parsedTabSize = parseInt(<string>newConfiguration.tabSize, 10);
if (!isNaN(parsedTabSize)) {
newOpts.tabSize = parsedTabSize;
}
newOpts.tabSize = newConfiguration.tabSize;
}
this._model.updateOptions(newOpts);
}