LuaLS / LuaLS/lua-language-server
Logic to sort diagnostics by cost doesn't work because of async processing
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
I found some logic in diagnostics/init.lua that doesn't work as expected: https://github.com/LuaLS/lua-language-server/blob/87abc4245f2a24e1cc35851b6464af9588934286/script/core/diagnostics/init.lua#L158 tries to sort diagnostics by cost to run cheap diags first.
However, the code to measure to runtime at https://github.com/LuaLS/lua-language-server/blob/87abc4245f2a24e1cc35851b6464af9588934286/script/core/diagnostics/init.lua#L180 does to by calling os.clock() before and after invoking a given diagnostic.
This doesn't work if the diagnostic yields during execution, and most diagnostics do exactly that via `await.delay()`. The end result is that the order is pretty much random (which I confirmed by looking at the diagCost arrays with and without await.delay() enabled)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 script/core/diagnostics/init.lua 开始,查看第 158 行附近的排序逻辑和第 180 行附近的运行时测量。启用和禁用 await.delay(),比较诊断成本数组,以重现该问题。当诊断执行发生 yield 时,诊断仍能按照有意义的测量成本排序,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100