Rework properties not to use objects
Hello everyone.
Unfortunately, when I was adding some configuration properties (i.e., "rust.rustup") I didn't truly understand how the configuration parameters mechanism of Visual Studio Code worked.
As an example, "rust.rustup" is defined as:
"rust.rustup": {
"default": null,
"properties": {
"toolchain": {
"default": null
},
"nightlyToolchain": {
"default": null
}
}
},
First problem - default values of nested properties don't work
"rust.rls"'s properties define default values, but they don't work.
It's intentional, but I didn't know about that.
A workaround is to define a default value for "rust.rls" which will contain default values of its properties therefore it's not a big deal.
Second problem - it's very complex to set only one parameter of some object
As #339 states, it would be good if the extension could save the toolchain chosen by the user to the workspace configuration. It could be implemented by it involves very complex checks and it might contain some possible problems which would happen later.
Solution
As guys on gitter said me, nobody use objects and it is surprising that it is supported at all.
All configuration parameters which type is "object" and which define nested properties must be split into multiple configuration parameters.
As an example, "rust.rls" must be split into:
-
"rust.rls.executable" -
"rust.rls.args" -
"rust.rls.env" -
"rust.rls.revealOutputChannelOn" -
"rust.rls.useRustfmt"
The following configuration parameters must be split:
-
"rust.rustup" -
"rust.rls"
Of course the code accessing the configuration parameters must be reworked.
I would be happy if someone did it at least for one configuration parameter.
I've started working on it.