Setting - redhat-developer/vscode-extension-tester GitHub Wiki
Lookup
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');
Retrieve Information
// get the title
const title = setting.getTitle();
// get the category
const category = setting.getCategory();
// get the description
const description = await setting.getDescription();
Handling Values
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");
Setting Value Types
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
.