-
Notifications
You must be signed in to change notification settings - Fork 118
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
Defaults not always correct #3
Comments
I found the solution. Will do a PR tomorrow :). |
Excellent! I look forward to seeing the solution. Thanks for your dedication to this extension! |
Damn, I though I had it but unfortunately I was wrong. This is what I thought was working. Instead of creating an entirely new options object for if (editorConfig.indent_style) {
textEditor.options.insertSpaces = editorConfig.indent_style !== 'tab';
}
if (editorConfig.indent_size || editorConfig.tab_size) {
textEditor.options.tabSize = editorConfig.tab_width || editorConfig.indent_size;
} I thought that when
This is the issue I created in the VSCode repo. microsoft/vscode#2797 |
@SamVerschueren if the vscode logic is working as you theorize, what if we use |
No, because when the usersettings are set to But we as a plugin are not able to retrieve that detected value. Actually we can, but our code is invoked before VS Code detects the settings. So this is the flow without our plugin
This is the flow with our plugin
Does this make things clear :)? It's difficult to explain :p. |
Thanks for the explanation. If I understand correctly, you're saying that the moment we've tampered with the After slowly reading your comment, it seems to me that the problem only presents itself when you want to apply "some" settings, but not necessarily all of them. In your comment's example, you want If, however, the future allowed us to support the I get it now, I think. You're right that it's hard to explain. I can't just quickly read your explanation or I'll be confused. I guess we just track microsoft/vscode#2797 until we can move forward with this. |
It only bails out when you apply an entirely new object. But only tampering one of the two like this textEditor.options.insertSpaces = true; isn't working. It doesn't take that setting. So what I understand from this is that VS Code looks at the options object reference to determine if it should apply user settings or not.
Exactly! |
That's very odd that modifying one setting doesn't work. They need to fix that! |
I think that is how they determine if the object was modified. Something (pseudo-codeish) like this const _options = {
insertSpaces: false,
tabSize: 4
};
const initialReference = _options;
Object.defineProperty(textEditor, 'options', {
get: () => _options,
set: (newOptions) => {
_options = newOptions;
}
});
// ...
if(_options === initialReference) {
// Object was not modified, parse the settings and auto-detect if value is "auto"
} else {
// Do nothing because the object was modified by a plugin
} I'm not sure though because I can't find the code that is responsible for this. It's just how I think it is implemented depending on the behaviour I see. A solution would be to be able to pass in textEditor.option = { insertSpaces: true }; Because Or off course fix the behaviour to be able to modify one setting directly. textEditor.option.insertSpaces = true; |
this block tries to use the defaults of the texteditor and in my case, in most circumstances, it works. But not always. Let's assume we have this
.editorconfig
file.Expected behaviour
If my VS Code settings of
insertSpaces
is set toauto
, it should auto-detect the the indentation type (spaces or tabs). This means that if I openindex.js
, (which uses tabs) it should detect thetabs
and use that is indent style.Current behaviour
package.json
as the FIRST file (this will setspaces
as default indent type)index.js
(which uses tabs) and it will use spaces as current indent typeI will create an issue in the VSCode issue tracker and link this one. They have to refactor the API in order for us to support automatically detected defaults by VS Code.
The text was updated successfully, but these errors were encountered: