Skip to content

Commit 484e0cb

Browse files
committed
Create a new API proposal with TextEditorOptions.indentSize
1 parent 357f4e9 commit 484e0cb

File tree

6 files changed

+38
-17
lines changed

6 files changed

+38
-17
lines changed

src/vs/editor/contrib/indentation/browser/indentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export class ChangeIndentationSizeAction extends EditorAction {
233233
: n === creationOpts.tabSize
234234
? nls.localize('defaultTabSize', "Default Tab Size")
235235
: n === modelOpts.tabSize
236-
? nls.localize('selectedTabSize', "Selected Tab Size")
236+
? nls.localize('currentTabSize', "Current Tab Size")
237237
: undefined
238238
)
239239
}));

src/vs/workbench/api/common/extHostTextEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ export class ExtHostTextEditorOptions {
165165
set tabSize(value: number | string) {
166166
that._setTabSize(value);
167167
},
168-
get indentSize(): number | string {
168+
get indentSize(): number | 'tabSize' {
169169
return that._indentSize;
170170
},
171-
set indentSize(value: number | string) {
171+
set indentSize(value: number | 'tabSize') {
172172
that._setIndentSize(value);
173173
},
174174
get insertSpaces(): boolean | string {

src/vs/workbench/api/test/browser/extHostTextEditor.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ suite('ExtHostTextEditorOptions', () => {
258258
});
259259

260260
test('can change indentSize to a string number', () => {
261-
opts.value.indentSize = '2';
261+
opts.value.indentSize = <any>'2';
262262
assertState(opts, {
263263
tabSize: 4,
264264
indentSize: 2,
@@ -282,7 +282,7 @@ suite('ExtHostTextEditorOptions', () => {
282282
});
283283

284284
test('indentSize cannot request indentation detection', () => {
285-
opts.value.indentSize = 'auto';
285+
opts.value.indentSize = <any>'auto';
286286
assertState(opts, {
287287
tabSize: 4,
288288
indentSize: 4,
@@ -318,7 +318,7 @@ suite('ExtHostTextEditorOptions', () => {
318318
});
319319

320320
test('ignores invalid indentSize 3', () => {
321-
opts.value.indentSize = 'hello';
321+
opts.value.indentSize = <any>'hello';
322322
assertState(opts, {
323323
tabSize: 4,
324324
indentSize: 4,
@@ -330,7 +330,7 @@ suite('ExtHostTextEditorOptions', () => {
330330
});
331331

332332
test('ignores invalid indentSize 4', () => {
333-
opts.value.indentSize = '-17';
333+
opts.value.indentSize = <any>'-17';
334334
assertState(opts, {
335335
tabSize: 4,
336336
indentSize: 4,

src/vs/workbench/services/extensions/common/extensionsApiProposals.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const allApiProposals = Object.freeze({
3636
findTextInFiles: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findTextInFiles.d.ts',
3737
fsChunks: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fsChunks.d.ts',
3838
idToken: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.idToken.d.ts',
39+
indentSize: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.indentSize.d.ts',
3940
inlineCompletionsAdditions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts',
4041
interactiveWindow: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveWindow.d.ts',
4142
ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts',

src/vscode-dts/vscode.d.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -641,22 +641,13 @@ declare module 'vscode' {
641641
/**
642642
* The size in spaces a tab takes. This is used for two purposes:
643643
* - the rendering width of a tab character;
644-
* - the number of spaces to insert when {@link TextEditorOptions.insertSpaces insertSpaces} is true
645-
* and `indentSize` is set to `"tabSize"`.
644+
* - the number of spaces to insert when {@link TextEditorOptions.insertSpaces insertSpaces} is true.
646645
*
647646
* When getting a text editor's options, this property will always be a number (resolved).
648647
* When setting a text editor's options, this property is optional and it can be a number or `"auto"`.
649648
*/
650649
tabSize?: number | string;
651650

652-
/**
653-
* The number of spaces to insert when [insertSpaces](#TextEditorOptions.insertSpaces) is true.
654-
*
655-
* When getting a text editor's options, this property will always be a number (resolved).
656-
* When setting a text editor's options, this property is optional and it can be a number or `"tabSize"`.
657-
*/
658-
indentSize?: number | string;
659-
660651
/**
661652
* When pressing Tab insert {@link TextEditorOptions.tabSize n} spaces.
662653
* When getting a text editor's options, this property will always be a boolean (resolved).
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
declare module 'vscode' {
7+
/**
8+
* Represents a {@link TextEditor text editor}'s {@link TextEditor.options options}.
9+
*/
10+
export interface TextEditorOptions {
11+
/**
12+
* The size in spaces a tab takes. This is used for two purposes:
13+
* - the rendering width of a tab character;
14+
* - the number of spaces to insert when {@link TextEditorOptions.insertSpaces insertSpaces} is true
15+
* and `indentSize` is set to `"tabSize"`.
16+
*
17+
* When getting a text editor's options, this property will always be a number (resolved).
18+
* When setting a text editor's options, this property is optional and it can be a number or `"auto"`.
19+
*/
20+
tabSize?: number | string;
21+
/**
22+
* The number of spaces to insert when [insertSpaces](#TextEditorOptions.insertSpaces) is true.
23+
*
24+
* When getting a text editor's options, this property will always be a number (resolved).
25+
* When setting a text editor's options, this property is optional and it can be a number or `"tabSize"`.
26+
*/
27+
indentSize?: number | 'tabSize';
28+
}
29+
}

0 commit comments

Comments
 (0)