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
Provide source info when reading configurations #10583
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.
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?
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).
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?
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.
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.
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.
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.
Activity
jrieken commentedon Aug 16, 2016
fyi Benjamin Pasero (@bpasero)
bpasero commentedon Aug 25, 2016
Johannes Rieken (@jrieken) I added
IConfigurationService.lookup(key)which returns a structure ofI think we should expose this to extensions via some kind of new API. Do you have ideas about naming etc?
jrieken commentedon Aug 25, 2016
Cool. Is there also some sort of
keyenumeration?bpasero commentedon Aug 25, 2016
Johannes Rieken (@jrieken) there is https://github.com/Microsoft/vscode/blob/master/src/vs/platform/configuration/common/model.ts#L180 which is currently not within the configuration service but can be used from anywhere.
jrieken commentedon Aug 25, 2016
My plan is to add an
inspectmethod to theWorkspaceConfigurationobject (along withupdate). 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 workgetConfiguration('files').get('watcherExclude.**/node_modules/**')(the latter is unaware of key vs object-values).jrieken commentedon Aug 25, 2016
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 haveworkspace-settings being undefined when not applicable?bpasero commentedon Aug 25, 2016
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,mainside and theworkbenchrenderer 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 forworkbench). We used to have it down there and it took some time and was very painful to get it out of there again.jrieken commentedon Aug 25, 2016
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.
bpasero commentedon Aug 25, 2016
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.
rebornix commentedon Aug 25, 2016
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
useCtrlKeysastrueon Mac butfalseon Windows. Since Code has no support for this kind of setting so we decide to initialize the default foruseCtrlKeyswhile the extension starts. So if there is auserCtrlKeysoption in Workspace or User settings, we just use the value. If not, we set it astrueon Mac,falseon 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
tabstopand Code'stabsize. So our plan about the config overridden priority is, if thevim.tabstopis set by purpose (workspace setting or user setting), we will use it to override Code'stabSize. 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
workspaceanduserinformation, 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.
32 remaining items
fix problem with getConfigurationValue, #10583
another ExtHostConfiguration test, #10583
bpasero commentedon Nov 4, 2016
Thx for the fix.
jrieken commentedon Nov 7, 2016
API proposal goes like this
Peng Lyu (@rebornix) Eric Amodio (@eamodio) Benjamin Pasero (@bpasero) feedback, ideas?
another ExtHostConfiguration test, #10583
bpasero commentedon Nov 7, 2016
Johannes Rieken (@jrieken) works for me 👍
eamodio commentedon Nov 7, 2016
Johannes Rieken (@jrieken) looks great to me too
rebornix commentedon Nov 7, 2016
Johannes Rieken (@jrieken) it's great! 🚢
Jakobud commentedon Nov 7, 2016
slightly off topic. I'm a bit of a noob on this subject I guess, but what does the
<T>mean?jrieken commentedon Nov 8, 2016
The
<T>is the actual type of the setting, likebooleanorstring