Readonly
isIndicates whether the service has successfully initialized. Will be true
when the ready
Promise resolves.
Registers a callback which will be called whenever a preference is changed.
Registers a callback which will be called whenever one or more preferences are changed.
Readonly
readyPromise indicating whether the service successfully initialized.
Retrieve the stored value for the given preference.
the preference identifier.
the value stored for the given preference when it exists, undefined
otherwise.
Retrieve the stored value for the given preference.
the preference identifier.
the value to return when no value for the given preference is stored.
the value stored for the given preference when it exists, otherwise the given default value.
Retrieve the stored value for the given preference and resourceUri.
the preference identifier.
the value to return when no value for the given preference is stored.
Optional
resourceUri: stringthe uri of the resource for which the preference is stored. This used to retrieve
a potentially different value for the same preference for different resources, for example files.encoding
.
the value stored for the given preference and resourceUri when it exists, otherwise the given default value.
Retrieve the stored value for the given preference and resourceUri.
the preference identifier.
Optional
defaultValue: Tthe value to return when no value for the given preference is stored.
Optional
resourceUri: stringthe uri of the resource for which the preference is stored. This used to retrieve
a potentially different value for the same preference for different resources, for example files.encoding
.
the value stored for the given preference and resourceUri when it exists, otherwise the given default value.
Returns the uri of the configuration resource for the given scope and optional resource uri.
the PreferenceScope to query for.
Optional
resourceUri: stringthe optional uri of the resource-specific preference handling
Optional
sectionName: stringthe optional preference section to query for.
the uri of the configuration resource for the given scope and optional resource uri it it exists,
undefined
otherwise.
Retrieve the stored value for the given preference and resourceUri in all available scopes.
the preference identifier.
Optional
resourceUri: stringthe uri of the resource for which the preference is stored.
Optional
forceLanguageOverride: booleanif true
and preferenceName
is a language override, only values for the specified override will be returned.
Otherwise, values for the override will be returned where defined, and values from the base preference will be returned otherwise.
an object containing the value of the given preference for all scopes.
For behavior, see PreferenceService.inspect.
Optional
resourceUri: stringOptional
forceLanguageOverride: booleanthe value in the scope specified.
Tries to split the given preference identifier into the original OverridePreferenceName attributes
with which this identifier was created. Returns undefined
if this is not possible, for example
when the given preference identifier was not generated by overridePreferenceName
.
This method is checked when resolving preferences. Therefore together with "overridePreferenceName" this can be used to handle specialized preferences, e.g. "[markdown].editor.autoIndent" and "editor.autoIndent".
the preferenceName which might have been created via PreferenceService.overridePreferenceName.
the OverridePreferenceName which was used to create the given preferenceName
if this was the case,
undefined
otherwise.
Returns a new preference identifier based on the given OverridePreferenceName.
the override specification.
the calculated string based on the given OverridePreferenceName.
Retrieve the stored value for the given preference and resourceUri.
the preference identifier.
Optional
defaultValue: Tthe value to return when no value for the given preference is stored.
Optional
resourceUri: stringthe uri of the resource for which the preference is stored. This used to retrieve
a potentially different value for the same preference for different resources, for example files.encoding
.
an object containing the value stored for the given preference and resourceUri when it exists, otherwise the given default value. If determinable the object will also contain the uri of the configuration resource in which the preference was stored.
Sets the given preference to the given value.
the preference identifier.
the new value of the preference.
Optional
scope: PreferenceScopethe scope for which the value shall be set, i.e. user, workspace etc. When the folder scope is specified a resourceUri must be provided.
Optional
resourceUri: stringthe uri of the resource for which the preference is stored. This used to store
a potentially different value for the same preference for different resources, for example files.encoding
.
a promise which resolves to undefined
when setting the preference was successful. Otherwise it rejects
with an error.
Determines and applies the changes necessary to apply value
to either the resourceUri
supplied or the active session.
If there is no setting for the preferenceName
, the change will be applied in user scope.
If there is a setting conflicting with the specified value
, the change will be applied in the most specific scope with a conflicting value.
the identifier of the preference to modify.
the value to which to set the preference. undefined
will reset the preference to its default value.
Optional
resourceUri: stringthe uri of the resource to which the change is to apply. If none is provided, folder scope will be ignored.
Service to manage preferences including, among others, getting and setting preference values as well as listening to preference changes.
Depending on your use case you might also want to look at createPreferenceProxy with which you can easily create a typesafe schema-based interface for your preferences. Internally the proxy uses the PreferenceService so both approaches are compatible.