是否可以使用 VSCode 擴展 API 更改嵌套設定?我已經四處搜索,似乎沒有任何關于此的討論。
例如,我如何使用getConfiguration().update()
來更改如下設定:
{
"workbench.colorCustomizations": {
"button.foreground": "#FFCC66", // <-- nested setting to change
// ...rest of nested settings
},
// rest of settings
}
如何button.foreground
使用點符號訪問“深層”屬性,例如嵌套屬性?
await vscode.workspace
.getConfiguration()
.update(
<nested-property>,
'#ffffff', // new button foreground color
vscode.ConfigurationTarget.Global
);
uj5u.com熱心網友回復:
弄清楚了。
// Get configuration for parent setting
const colorCustomizations: any = await vscode.workspace
.getConfiguration()
.get('workbench.colorCustomizations');
// Update nested setting
colorCustomizations['button.foreground'] = '#ffffff';
// Overwrite entire parent setting
await vscode.workspace
.getConfiguration()
.update(
'workbench.colorCustomizations',
colorCustomizations,
vscode.ConfigurationTarget.Global
);
感謝@rioV8 引導我朝著正確的方向前進。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/506622.html