LuaLS / LuaLS/lua-language-server
Inconsistent Go To Definition Behavior
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Type Checking
Expected Behaviour
Consider the following code:
---@class A
---@field t table<string, number>
---@field s string
---@class B
---@field a A
---@type B
local b = {
a = {
t = { x = 1 },
s = 'hi',
}
}
When you ctrl+click (or Go To Definition) on a inside the declaration of variable b, the cursor moves to ---@field a A in the type definition of class B. That's useful behavior. Similarly, when you do the same on s inside the nested a declaration, it goes to --@field s string in class A as expected.
When you click on t however (in t = { x = 1 }, it takes you to the builtin.lua meta file and places the cursor on the definition for tables @class table<K, V>: { [K]: V }. Not only is that behavior not consistent with the above, but it's also completely useless.
Another example (and probably different issue) is if you move the variable declaration to another file, like this:
File 1:
---@class A
---@field t table<string, number>
---@field s string
---@class B
---@field a A
File 2:
---@type B
local b = {
a = {
t = { x = 1 },
s = 'hi',
}
}
Now going to the definition of t still takes you to builtin.lua, but going to the definition of a, or s does nothing at all. I assume it's because it's treating their "definition" as the same line where they are declared in File 2.
Ideally I would like Go to Definition to do something useful inside table declarations and take me to the type annotation. But if that's not possible it should at least be consistent. In my opinion it should never take you to builtin.lua if there's another more suitable definition.
I think this worked fine in a previous version. I only started to see this behavior in the last few months.
Actual Behaviour
See above.
Reproduction steps
See above.
Additional Notes
No response
Log File
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue 内の Lua スニペットから始め、Windows 上の Visual Studio Code 拡張機能で Go To Definition を再現し、インライン宣言とファイル間宣言を比較します。フィールド t が builtin.lua に解決される一方で、a と s が異なる形で解決される理由を追跡します。完了の条件は、テーブルフィールドのナビゲーションが関連する型注釈に一貫して到達するか、builtin テーブルの定義を回避し、両方の例に対するリグレッションカバレッジがあることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100