LuaLS / LuaLS/lua-language-server
Defining table fields of a class across multiple files breaks auto-complete
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lua
- Star
- 4.4k
- Fork
- 442
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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
If we have a class such as:
---@class MyClass
MyClass = {
SomeTable = {
A = "Something",
},
}
Then another definition of it in another file (an "extension" of the class):
-- This file extends the MyClass class.
---@class MyClass
local MyClass = MyClass
MyClass.SomeTable.B = "Other thing"
Trying to access MyClass.SomeTable should show both A and B as options in auto-complete.
Actual Behaviour
If the keys of a table within a class are defined across multiple files, auto-complete will not work for them all. If you access these keys however, the hover tooltip will be correct and go-to-definition will work.
This is best understood with an example folder. I've attached it below and its code is also shown in the reproduction steps.
Reproduction steps
If you have a class definition in one file such as:
Class_Main.lua:
---@class MyClass
MyClass = {
SomeTable = {
A = "Something",
},
}
And you try to add keys to SomeTable in another file such as:
Class_Extensions.lua
-- This file extends the MyClass class.
---@class MyClass
local MyClass = MyClass
MyClass.SomeTable.B = "Other thing"
Then trying to access Class.SomeTable. in another file will not show B as an option in auto-complete. B will only show in auto-complete in the file were it was added, despite Class there being tagged with @class - which I would expect to add B to the class definition and not just the local usage of it.
UserCode.lua:
As mentioned previously, if you do access B by typing it manually, the hover tooltip will be correct and Ctrl+Click to go to definition will work as expected.
Additional Notes
Example folder replicating the issue is attached. It's the same example as the one shown above.
LLS_ClassExtensionBug.zip
Log File
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề bằng Class_Main.lua, Class_Extensions.lua và UserCode.lua từ báo cáo hoặc ví dụ đính kèm trong extension Visual Studio Code. Bắt đầu bằng cách theo dõi tính năng hoàn thành cho MyClass.SomeTable qua các tệp, đồng thời so sánh với hành vi hover và đi đến định nghĩa đã hoạt động. Hoàn thành khi tính năng hoàn thành liệt kê cả A và B lúc truy cập bảng từ một tệp khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100