Detect if setting is default or user-defined #183
-
Is there a way to fetch only the user settings that have been explicitly defined (i.e. exclude any "default" values). When an extension defines settings in vscode, each setting can define a default value. Then, when settings are retrieved using The problem is, there are situations where I want to include the defaults to improve user experience, but I need to know whether the user has explicitly defined the settings or not. Consider the following example: We add a new Consider this
The problem is, since there are default values, the default settings will be this. vscode.workspace.getConfiguration('yourExtension') {
"yourExtension": {
"feature1": [1, 2, 3],
"feature1Experimental": [3, 4, 5]
}
} There's no way to know whether the user specifically defined |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The EDIT: to correct a mistake that @eamodio pointed out |
Beta Was this translation helpful? Give feedback.
The
inspect
method onWorkspaceConfiguration
can do what you want. It lets you see the values at each layer of configuration. For example, if there is adefaultValue
but noglobalValue
,workspaceValue
,workspaceFolderValue
, etc., then the user has not explicitly set that setting.EDIT: to correct a mistake that @eamodio pointed out