You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow extensions to set configuration options. #1396
I've got an extension that I'm currently adding telemetry too so that I can better understand how people are using it, however I want to give users an easy way to opt out of this telemetry collection. My initial thoughts were that I would display a quick pick with two options (agree or disagree) and that I would then store their choice for later executions.
However, it looks like the configuration API for extensions doesn't support the option to set a configuration value. It would be great if I could do something like this:
Thanks Johannes Rieken (@jrieken). I'll look into that in the meantime. Are you considering allowing extensions to write settings or is using extension state the better approach for this kind of setting?
Not decided yet. The model of today is that only the user can modify settings and there is lot of good about that, but also see some shortcomings... The extension state is meant for remembering a user choice, store some installing path etc. This also includes your use-case. Since it's a little touchy (collecting telemetry data) I can understand that you want a more prominent option to unset something like that.
Closing as we believe the current story isn't too bad. User manually editor configuration options and extensions can persist settings etc globally/locally
Any configuration key that starts with launch.* or tasks.* ends up in those files in the workspace.
Does it mean it's asymmetric? So when I have 'foo: true' in launch.json and launch.foo: false in settings.json. From my understanding the latter value (false) will be the effective value but it seems now that writing will change the other value. Is that correct/desired?
Johannes Rieken (@jrieken) today it seems random who is winning in such a case. in my testing the 'launch.foo': false in settings.json is actually winning over the 'foo: true' in launch.json which seems somewhat unexpected.
I think when merging settings in our config model we should first take all settings from settings.json and then overwrite the ones found in any other JSON file.
Benjamin Pasero (@bpasero) I just tried this and seems to work great! It would be lovely if we could format the launch.json / tasks.json / settings.json after editing it. Here is a small gif where I am adding a new configuration using the API after the hello world command
You can show me how you've solved the problem. In my extension I want to get all the keys from settings.json and replace where there is a flag of my extension. It is possible?
Activity
jrieken commentedon Dec 17, 2015
Mitch Denny (@mitchdenny) You can also use the extension state for storage (https://code.visualstudio.com/docs/extensionAPI/vscode-api#ExtensionContext)
mitchdenny commentedon Dec 18, 2015
Thanks Johannes Rieken (@jrieken). I'll look into that in the meantime. Are you considering allowing extensions to write settings or is using extension state the better approach for this kind of setting?
jrieken commentedon Dec 18, 2015
Not decided yet. The model of today is that only the user can modify settings and there is lot of good about that, but also see some shortcomings... The extension state is meant for remembering a user choice, store some installing path etc. This also includes your use-case. Since it's a little touchy (collecting telemetry data) I can understand that you want a more prominent option to unset something like that.
mitchdenny commentedon Dec 19, 2015
Thanks for getting back to me. Appreciate it.
Adding to DotJoshJohnson#6 - user setting to persist the last query
jrieken commentedon Apr 13, 2016
Closing as we believe the current story isn't too bad. User manually editor configuration options and extensions can persist settings etc globally/locally
jrieken commentedon Jun 8, 2016
We have decided to open up that way - giving extensions the power to modify the configuration outweighs the risks.
48 remaining items
jrieken commentedon Sep 19, 2016
Does it mean it's asymmetric? So when I have
'foo: true'inlaunch.jsonandlaunch.foo: falseinsettings.json. From my understanding the latter value (false) will be the effective value but it seems now that writing will change the other value. Is that correct/desired?Revert "undo update change for now, #1396"
bpasero commentedon Sep 19, 2016
Johannes Rieken (@jrieken) today it seems random who is winning in such a case. in my testing the
'launch.foo': falseinsettings.jsonis actually winning over the'foo: true'inlaunch.jsonwhich seems somewhat unexpected.I think when merging settings in our config model we should first take all settings from
settings.jsonand then overwrite the ones found in any other JSON file.bpasero commentedon Sep 19, 2016
Pushed a change to ensure that any value in
tasks.jsonorlaunch.jsonoverwrites anything insettings.jsonunder the same key.allow a workspace config to replace its entire contents (for #1396)
bpasero commentedon Sep 19, 2016
Andre Weinand (@weinand) Isidor Nikolic (@isidorn) Dirk Bäumer (@dbaeumer) I pushed a change so that you can actually replace the entire contents when you use the
tasksorlaunchkey. This is only possible in those cases 👍allow a workspace config to replace its entire contents (for #1396)
isidorn commentedon Sep 20, 2016
Benjamin Pasero (@bpasero) I just tried this and seems to work great! It would be lovely if we could format the launch.json / tasks.json / settings.json after editing it. Here is a small gif where I am adding a new configuration using the API after the hello world command
bpasero commentedon Sep 20, 2016
Isidor Nikolic (@isidorn) is that changing an existing launch.json or creating a brand new one?
isidorn commentedon Sep 20, 2016
Benjamin Pasero (@bpasero) that is changing an existing
launch.json. When I create a brand newlaunch.jsonit is nicely formated.bpasero commentedon Sep 20, 2016
Isidor Nikolic (@isidorn) actually I can reproduce and this seems to happen when you pass in a complex object to Martin Aeschlimann (@aeschli) method
applyEditshttps://github.com/Microsoft/vscode/blob/master/src/vs/base/common/jsonFormatter.ts#L34The formatting seems to be ok'ish preserved if you just change simple key-value pairs, but not for such larger objects.
As a workaround you could just get the configuration and set it fully because then I am applying it using
JSON.stringify().isidorn commentedon Sep 20, 2016
Benjamin Pasero (@bpasero) thanks for the workaround!
leonardovilarinho commentedon Nov 18, 2017
Hi Benjamin Pasero (@bpasero) or Isidor Nikolic (@isidorn) ,
You can show me how you've solved the problem. In my extension I want to get all the keys from settings.json and replace where there is a flag of my extension. It is possible?