-
Notifications
You must be signed in to change notification settings - Fork 29.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing TextEditor.options issues #2797
Comments
These are my findings. Please let me know if I'm wrong :). So internally VS Code has some decision check wether it should recalculate the settings for a file in the text editor. Based on some debugging, it looks like the decision looks like this.
Because when I only change one value This is how this issue can be resolved. Values passed in as textEditor.options = {
insertSpaces: true,
tabSize: undefined
};
// OR
textEditor.options = {
insertSpaces: true
}; If my global |
@SamVerschueren you can get the right GitHub code coloring for root = true
[*]
indent_style = tab
[{package.json,*.yml}]
indent_style = space
indent_size = 2 |
@jedmao Thanks :) |
@alexandrudima This issue is thoroughly discussed here editorconfig/editorconfig-vscode#3 |
@alexandrudima It looks like I found a solution in editorconfig/editorconfig-vscode#5. It looks like the interface TextEditorOptions {
tabSize: number,
insertSpaces: boolean
} Which makes it not possible to provide |
For the record, you're referring to these lines. Would Microsoft be willing to update this interface or is there a good reason they don't use union types for these settings? |
Did a PR #2935 I guess they will accept it as I don't see any reason to not allow strings. |
fix TextEditorOptions declaration - fixes #2797
Thank you for the PR! 👍 I went a bit further to try to clarify things: export interface TextEditorOptions {
/**
* The size in spaces a tab takes. This is used for two purposes:
* - the rendering width of a tab character;
* - the number of spaces to insert when [insertSpaces](#TextEditorOptions.insertSpaces) is true.
* When getting a text editor's options, this property will always be a number (resolved).
* When setting a text editor's options, this property is optional and it can be a number or `"auto"`.
*/
tabSize?: number | string;
/**
* When pressing Tab insert [n](#TextEditorOptions.tabSize) spaces.
* When getting a text editor's options, this property will always be a boolean (resolved).
* When setting a text editor's options, this property is optional and it can be a boolean or `"auto"`.
*/
insertSpaces?: boolean | string;
} |
We are working on the EditorConfig plugin and we have issues regarding
TextEditor.options
.Users don't have to specify values for let's say
indent_style
. Let's take the following.editorconfig
And my VSCode settings file looks like this
If I open
package.json
, the style should be set tospace
and the indent size to2
. If I openindex.js
, it should set thestyle
totab
and take the global setting (which isauto
) so it should be calculated by VS Code itself. At the moment this is not possible. Because you have to overwrite the entire object which prevents auto-calculating the indent size.@alexandrudima I think you are in charge for something like this :)?
The text was updated successfully, but these errors were encountered: