LuaLS / LuaLS/lua-language-server
Auto-complete for table keys with @type breaks on non-locals
未关闭
还没有人认领这个 Issue。
feat/LuaCats Annotations
feat/type check
- 主要语言
- 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?
Completion
Expected Behaviour
Using ---@type table<KeyType, ValueType> on a table should always keep auto-complete available for keys within the table.
Actual Behaviour
Auto-complete breaks if the table that ---@type was used on is global or within a class.
Reproduction steps
Scenario where auto-complete works:
---@class MyClass
---@field MyThings any
---@type table<string, MyClass>
local SomeTable = {
SomeKey = {MyField = 1},
SomeKey2 = {MyField = 1},
}
Scenario where auto-complete does not work:
---@class MyClass
---@field MyThings any
---@type table<string, MyClass>
SomeTable = {
SomeKey = {MyField = 1},
SomeKey2 = {MyField = 1},
}
No auto-complete will be available for SomeTable there. This also occurs if SomeTable is within a table marked with ---@class.
Additional Notes
No response
Log File
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 Visual Studio Code extension 中重现两个表键补全场景,比较使用 table<KeyType, ValueType> 注解的局部表、全局表和类内表。跟踪这些注解的补全处理,并验证在每个场景中键补全仍然可用。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100