LuaLS / LuaLS/lua-language-server

Logic to sort diagnostics by cost doesn't work because of async processing

未關閉
#2,677 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 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)

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 script/core/diagnostics/init.lua 開始,查看第 158 行附近的排序邏輯和第 180 行附近的執行時間測量。啟用和停用 await.delay(),比較診斷成本陣列,以重現此問題。當診斷執行發生 yield 時,診斷仍能依照有意義的測量成本排序,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
lua
領域
tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。