VS Code extension - set config enum values programmatically

Viewed 1297

I went through VS Code's documentation and Googled it but I cannot find is it possible to programmatically change the enums used in the config section of a custom extension. I need to change the enum as a whole - as an Array, not to a single - String - value.

For example, take this code (taken from VS Code's official docs)

 "gitMagic.blame.heatmap.location": {
    "type": "string",
    "default": "right",
    "enum": ["left", "middle", "right"] // this
 }

Is it possible to change the enum property runtime?

1 Answers

Edited: Try this:

import * as vscode from 'vscode';
await vscode.workspace.getConfiguration().update("gitMagic.blame.heatmap.location", "right", vscode.ConfigurationTarget.Global);

See more information here.

Related