Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code 用于修改文件的VSCode扩展名。排除配置_Visual Studio Code_Vscode Extensions - Fatal编程技术网

Visual studio code 用于修改文件的VSCode扩展名。排除配置

Visual studio code 用于修改文件的VSCode扩展名。排除配置,visual-studio-code,vscode-extensions,Visual Studio Code,Vscode Extensions,目前,我正在尝试编写一个扩展,允许我通过在文件中添加/删除/修改条目来动态更改工作区筛选器。排除配置元素并将其存储在工作区设置中 运行这样的命令,例如修改基于字符串或数组的配置,可以按预期工作: const config = vscode.workspace.getConfiguration(); config.update('editor.fontSize', 14, false); -> works 但我就是不知道如何修改基于对象的配置,比如files.exclude。 我尝试了不同

目前,我正在尝试编写一个扩展,允许我通过在
文件中添加/删除/修改条目来动态更改工作区筛选器。排除
配置元素并将其存储在工作区设置中

运行这样的命令,例如修改基于字符串或数组的配置,可以按预期工作:

const config = vscode.workspace.getConfiguration();
config.update('editor.fontSize', 14, false); -> works
但我就是不知道如何修改基于对象的配置,比如
files.exclude
。 我尝试了不同的方法,但总是得到一个错误,说我正在访问一个不存在的元素

config.update('files.exclude.TestXYZ', false, false); -> doesn't work
config.update('TestXYZ', false, false); -> doesn't work
预先对对象进行硬编码,并将其用作配置的新值

let settings = { "*.html": true, "*.css": true };
config.update('files.exclude', settings, false); -> works, but isn't what I need
但是为了编写一个可配置的工作区过滤器,我需要动态地从过滤器列表中添加/删除值

除此之外(但没有那么重要):我也无法“读取”
文件的当前值。我总是得到一个代理对象,我不是typescript tbh中的专业人士


最初的想法是阅读配置,进行修改并将其保存回去,但经过数小时的尝试后,只要它有效,我就可以完全覆盖它们。

通过@Gama11提供的有用链接,我能够实现我想要的结果:

const config = vscode.workspace.getConfiguration(); 
var excludeList: {[k: string]: boolean} = {}; 
excludeList[*.html] = true; 
excludeList[*.css] = true;
config.update('files.exclude', excludeList, false);

有了它,我可以动态地更改excludeList并相应地更新配置。

我想这更像是一个TS问题。像这样的东西有用吗?另外:@Gama11:非常感谢,它起作用了:D