xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
229 stars 54 forks source link

当我的工程中有target类型是headeronly时xmake插件不起作用 #129

Open v-dao opened 2 years ago

v-dao commented 2 years ago

Xmake 版本

2.6.8

操作系统版本和架构

Windows 10 专业版 21H2

描述问题

只要配置文件中有target的类型是headeronly插件会崩掉,我跟了插件的代码发现是explorer.ts:222中代码

if (target.files != null) {
    target.file.sort();
} else {
    target.files = []
}

修改为

const filekeys = Object.keys(target.files);
if (target.files != null && filekeys.length != 0) {
    target.files.sort();
} else {
    target.files = [];
}

因为是headeronly没有使用add_files添加文件,target.files不是null是一个空对象,调用了sort就崩掉了。我不知道ts怎么优雅的修复这个bug,这么判断之后不会崩溃了。

期待的结果

正常加载xmake插件

工程配置

target("demo") set_kind("headeronly") add_includedirs("include", {public = true})

附加信息和错误日志

No response

waruqi commented 2 years ago

可以来个pr