Skip to content

Provide source info when reading configurations #10583

Closed

Description

@rebornix
  • VSCode Version: 1.5.0-Insiders
  • OS Version: Windows 10

As discussed in #9731, we have no idea where an option is defined (default, user settings or workspace settings) when reading it by vscode.workspace.getConfiguration("section").get("optionName"). While in extensions, sometimes we may want to know whether users set options explicitly instead of using the default one but currently we don't support this kind of API.

cc Martin Aeschlimann (@aeschli)

Activity

  1. jrieken commented on Aug 16, 2016

    @jrieken
    Contributor
  2. added
    feature-request
    on Aug 16, 2016
  3. bpasero commented on Aug 25, 2016

    @bpasero
    Contributor

    Johannes Rieken (@jrieken) I added IConfigurationService.lookup(key) which returns a structure of

    IConfigurationValue<T>
    {
       default: T
       user: T
       workspace: T
       value: T (<-- this is the merged value of them all, with higher priority to workspace and user setting)
    }
    

    I think we should expose this to extensions via some kind of new API. Do you have ideas about naming etc?

  4. jrieken commented on Aug 25, 2016

    @jrieken
    Contributor

    Cool. Is there also some sort of key enumeration?

  5. bpasero commented on Aug 25, 2016

    @bpasero
    Contributor
  6. jrieken commented on Aug 25, 2016

    @jrieken
    Contributor

    My plan is to add an inspect method to the WorkspaceConfiguration object (along with update). The only catch is that users might pick a partial key in which case both methods would bail out.

    For instance, such a call won't work getConfiguration('files').update('watcherExclude.**/node_modules/**', true) whereas this does work getConfiguration('files').get('watcherExclude.**/node_modules/**') (the latter is unaware of key vs object-values).

  7. jrieken commented on Aug 25, 2016

    @jrieken
    Contributor

    Benjamin Pasero (@bpasero) Why is there the separation between workspace-config-service and the other config-service. I looks rather artificial, esp. with the lower-layer already knowing about user-settings. Why not merge them and have workspace-settings being undefined when not applicable?

  8. bpasero commented on Aug 25, 2016

    @bpasero
    Contributor

    Johannes Rieken (@jrieken) the split between a configuration service in platform and the one in workbench was done because we use the configuration service in many more environments: CLI, shared process, main side and the workbench renderer side. Pushing the notion of workspaces down to the platform layer was very bad for those areas where we do not have nor want a notion of workspaces (which is all of them except for workbench). We used to have it down there and it took some time and was very painful to get it out of there again.

  9. jrieken commented on Aug 25, 2016

    @jrieken
    Contributor

    I am not saying that you should push down the implementation but the interface. Now depending on where my code lives my service dependency changes which weakens the whole point of having interfaces and injections.

  10. bpasero commented on Aug 25, 2016

    @bpasero
    Contributor

    Peng Lyu (@rebornix) in your summary you ask for a way to find out if a setting is defined in user vs workspace land but it is unclear to me why that is needed? Can you share the use case for this? Would you be OK to just have a method that tells you if a setting is defined by the user or not?

    Johannes Rieken (@jrieken) if we do not need to distinguish between user and workspace setting then maybe we can simplify this altogether and we do not need the services separation for this case.

  11. rebornix commented on Aug 25, 2016

    @rebornix
    ContributorAuthor

    Benjamin Pasero (@bpasero) the reason I separated them is that I'm not sure which category Workspace settings belong to. Workspace overrides User and User overrides Default, there are some similarities between Workspace and User settings, they are set by purpose. To some extent, Workspace setting is like a Super User setting which has the highest priority.

    A user case for workspace info is VSCodeVim/Vim#595 , we want to set useCtrlKeys as true on Mac but false on Windows. Since Code has no support for this kind of setting so we decide to initialize the default for useCtrlKeys while the extension starts. So if there is a userCtrlKeys option in Workspace or User settings, we just use the value. If not, we set it as true on Mac, false on Windows. In this case, a method that tells you if a setting is defined by the user or not? is not enough.

    Another user case is about the overlap between Code's config and Vim's. For example, Vim's tabstop and Code's tabsize. So our plan about the config overridden priority is, if the vim.tabstop is set by purpose (workspace setting or user setting), we will use it to override Code's tabSize. So if the method you suggest tells me the config is not defined by user, I still have no idea whether it's defined in Workspace or not.

    With both workspace and user information, above two features can be implemented easily but there might be workarounds, let me know if you have any suggestion.

    But if you guys do think separating workspace and user makes the code complicated and bad, I'm Okay with Benjamin Pasero (@bpasero) 's proposal. These two features are not Vim blockers.

  12. 32 remaining items

  13. bpasero commented on Nov 4, 2016

    @bpasero
    Contributor

    Thx for the fix.

  14. jrieken commented on Nov 7, 2016

    @jrieken
    Contributor

    API proposal goes like this

    inspect<T>(section: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T };

    Peng Lyu (@rebornix) Eric Amodio (@eamodio) Benjamin Pasero (@bpasero) feedback, ideas?

  15. bpasero commented on Nov 7, 2016

    @bpasero
    Contributor

    Johannes Rieken (@jrieken) works for me 👍

  16. eamodio commented on Nov 7, 2016

    @eamodio
    Contributor

    Johannes Rieken (@jrieken) looks great to me too

  17. rebornix commented on Nov 7, 2016

    @rebornix
    ContributorAuthor
  18. Jakobud commented on Nov 7, 2016

    @Jakobud

    slightly off topic. I'm a bit of a noob on this subject I guess, but what does the <T> mean?

  19. jrieken commented on Nov 8, 2016

    @jrieken
    Contributor

    The <T> is the actual type of the setting, like boolean or string

  20. locked and limited conversation to collaborators on Nov 18, 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

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions