Allow setting indent size to an explicit number when it is computed from tab size (#200368)

Allow setting indent size to an explicit number when it is computed from tab size (fixes #199791)
This commit is contained in:
Alexandru Dima
2023-12-08 16:11:14 +01:00
committed by GitHub
parent a67b341968
commit 15c649493f
4 changed files with 14 additions and 7 deletions

View File

@@ -144,6 +144,7 @@ export class ExtHostTextEditorOptions {
private _tabSize!: number;
private _indentSize!: number;
private _originalIndentSize!: number | 'tabSize';
private _insertSpaces!: boolean;
private _cursorStyle!: TextEditorCursorStyle;
private _lineNumbers!: TextEditorLineNumbersStyle;
@@ -195,6 +196,7 @@ export class ExtHostTextEditorOptions {
public _accept(source: IResolvedTextEditorConfiguration): void {
this._tabSize = source.tabSize;
this._indentSize = source.indentSize;
this._originalIndentSize = source.originalIndentSize;
this._insertSpaces = source.insertSpaces;
this._cursorStyle = source.cursorStyle;
this._lineNumbers = TypeConverters.TextEditorLineNumbersStyle.to(source.lineNumbers);
@@ -266,12 +268,13 @@ export class ExtHostTextEditorOptions {
return;
}
if (typeof indentSize === 'number') {
if (this._indentSize === indentSize) {
if (this._originalIndentSize === indentSize) {
// nothing to do
return;
}
// reflect the new indentSize value immediately
this._indentSize = indentSize;
this._originalIndentSize = indentSize;
}
this._warnOnError('setIndentSize', this._proxy.$trySetOptions(this._id, {
indentSize: indentSize
@@ -350,9 +353,10 @@ export class ExtHostTextEditorOptions {
if (indentSize === 'tabSize') {
hasUpdate = true;
bulkConfigurationUpdate.indentSize = indentSize;
} else if (typeof indentSize === 'number' && this._indentSize !== indentSize) {
} else if (typeof indentSize === 'number' && this._originalIndentSize !== indentSize) {
// reflect the new indentSize value immediately
this._indentSize = indentSize;
this._originalIndentSize = indentSize;
hasUpdate = true;
bulkConfigurationUpdate.indentSize = indentSize;
}