node.js - 无法写入工作区设置,因为 .. 不是注册配置
问题描述
我正在尝试使用配置和工作区更新 VScode Setting.json 中的状态栏颜色。但是当代码尝试更新时,我收到以下错误:
Error: Unable to write to Workspace Settings because workbench.colorCustomizations.statusBar.background is not a registered configuration.
这是我的代码:
const conf = workspace.getConfiguration("workbench.colorCustomizations");
console.log('config-->'+JSON.stringify(conf));
await conf.update( "statusBar.background", "#00AA00");
在 GetConfiguration 上,我得到了现有的 StatusBar 颜色值,但无法更新它。
解决方案
也许它默认为工作区。如果您想更新它,即使您还没有打开工作区,也可以指定全局。
如果不指定目标,它可能会这样做:
await conf.update("statusBar.background", "#00AA00", vscode.ConfigurationTarget.Workspace);
您可能想要这样做:
await conf.update("statusBar.background", "#00AA00", vscode.ConfigurationTarget.Global);
推荐阅读
- laravel - 直邮阿里巴巴总是用 Laravel 去垃圾邮件
- r - 循环遍历许多对物种模型以增强 R 中的相关系数
- ocaml - 在 OCaml 中解析数学输入?
- python - 为什么我用 Pip 安装模块后不能在 VS Code 中使用模块
- jquery - 如何从服务器加载带有弹出窗口(JQuery mobile)的文本?
- php - 迭代结果时尝试获取非对象的属性
- linux - 列出在给定目录中运行的进程
- android - 如何使用 FirebaseListAdapter 维护包含扩展 ListView 的 ScrollView 的滚动位置
- ansible - Ansible 查找文件并遍历每个文件
- python - 使用 VScode 在 python 中导入模块时出错