LuaLS / LuaLS/lua-language-server
Adding ---@class breaks auto completion
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?
Linux
What is the issue affecting?
Completion
Expected Behaviour
I'm running into an issue where adding the ---@class annotation to a local variable seems to break auto completion. It should appear correctly even if the ---@class is affixed to a local variable.
Actual Behaviour
The autocomplete variables and functions are not appearing.
Reproduction steps
Here is a simple example of creating a new player class with the issue.
-- Here is a simple example of creating a new player class with the issue
-- Uncommenting the line below *breaks* the autocompletion for p.new()
-- ---@class err.Player
local Player = {}
Player.__index = Player
local function mixin_xy(o)
o.x = 0
o.y = 0
o.set_position = function(self, x, y)
self.x = x
self.y = y
end
return o
end
function Player.new()
local self = {}
self.happy = true
self = mixin_xy(self)
return setmetatable(self, Player)
end
local p = Player.new()
-- `p:set_position(), p.x, p.y, p.happy` no longer showing in auto complete if `---@class err.Player` is uncommented
When ---@class err.Player is uncommented, and above local Player = {}:
When ---@class err.Player is removed or commented:
The above image is the expected behaviour. However, when ---@class err.Player is added above local Player = {} it no longer works.
Additional Notes
No response
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 đề trong extension Visual Studio Code bằng ví dụ Lua trong báo cáo, so sánh tính năng hoàn thành khi có và không có annotation ---@class err.Player. Theo dõi quá trình xử lý hoàn thành cho các annotation lớp và xác minh rằng p:set_position(), p.x, p.y và p.happy xuất hiện khi annotation có mặt.
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
- 45/100