Skip to content

Allow extensions to set configuration options. #1396

Closed

Description

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:

let configuration = vscode.workspace.getConfiguration('ecdc');
configuration.set('collectTelemetry', false);

I'm sure other extensions would find this useful as well to help guide users to setting up sensitive defaults.

Activity

  1. added
    feature-request
    on Dec 17, 2015
  2. jrieken commented on Dec 17, 2015

    @jrieken
    Contributor
  3. mitchdenny commented on Dec 18, 2015

    @mitchdenny
    MemberAuthor

    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?

  4. jrieken commented on Dec 18, 2015

    @jrieken
    Contributor

    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.

  5. mitchdenny commented on Dec 19, 2015

    @mitchdenny
    MemberAuthor

    Thanks for getting back to me. Appreciate it.

  6. added a commit that references this issue on Dec 21, 2015
  7. jrieken commented on Apr 13, 2016

    @jrieken
    Contributor

    Closing as we believe the current story isn't too bad. User manually editor configuration options and extensions can persist settings etc globally/locally

  8. jrieken commented on Jun 8, 2016

    @jrieken
    Contributor

    We have decided to open up that way - giving extensions the power to modify the configuration outweighs the risks.

  9. 48 remaining items

  10. jrieken commented on Sep 19, 2016

    @jrieken
    Contributor

    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?

  11. bpasero commented on Sep 19, 2016

    @bpasero
    Contributor

    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.

  12. bpasero commented on Sep 19, 2016

    @bpasero
    Contributor

    Pushed a change to ensure that any value in tasks.json or launch.json overwrites anything in settings.json under the same key.

  13. bpasero commented on Sep 19, 2016

    @bpasero
    Contributor

    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 tasks or launch key. This is only possible in those cases 👍

  14. isidorn commented on Sep 20, 2016

    @isidorn

    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

    formatme

  15. bpasero commented on Sep 20, 2016

    @bpasero
    Contributor

    Isidor Nikolic (@isidorn) is that changing an existing launch.json or creating a brand new one?

  16. isidorn commented on Sep 20, 2016

    @isidorn

    Benjamin Pasero (@bpasero) that is changing an existing launch.json. When I create a brand new launch.json it is nicely formated.

  17. bpasero commented on Sep 20, 2016

    @bpasero
    Contributor

    Isidor Nikolic (@isidorn) actually I can reproduce and this seems to happen when you pass in a complex object to Martin Aeschlimann (@aeschli) method applyEdits https://github.com/Microsoft/vscode/blob/master/src/vs/base/common/jsonFormatter.ts#L34

    The 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().

  18. isidorn commented on Sep 20, 2016

    @isidorn

    Benjamin Pasero (@bpasero) thanks for the workaround!

  19. leonardovilarinho commented on Nov 18, 2017

    @leonardovilarinho

    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?

  20. locked and limited conversation to collaborators on Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apifeature-request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions