-
Notifications
You must be signed in to change notification settings - Fork 72
Setting
github-actions[bot] edited this page May 16, 2024
·
5 revisions
Settings can be located through a SettingsEditor object:
import { Workbench } from 'vscode-extension-tester';
...
// open the settings editor and get a handle on it
const settingsEditor = await new Workbench().openSettings();
// look for a setting named 'Auto Save' under 'Editor' category
const setting = await settingsEditor.findSetting('Auto Save', 'Files');
// get the title
const title = setting.getTitle();
// get the category
const category = setting.getCategory();
// get the description
const description = await setting.getDescription();
All setting types share the same functions to manipulate their values, however the value types and possible options vary between setting types.
// generic value retrieval
const value = await setting.getValue();
// generic setting of a value
await setting.setValue("off");
Currently, there are four supported types of setting values: text box, combo box, checkbox, link and array of strings.
- Text box allows putting in an arbitrary string value, though there might be value checks afterwards that are not handled by this class.
-
Combo box only allows inputs from its range of options. If you cast the setting to
ComboSetting
, you will be able to retrieve these options by calling thegetValues
method. - Check box only accepts boolean values, other values are ignored
-
Link does not have any value,
getValue
andsetValue
throw an error. Instead, casting the object toLinkSetting
will allow you to call theopenLink
method, which will open settings.json file in a text editor. -
Array settings are supported for type
string
. Each row of array is represented byArraySettingItem
.