Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Adding ---@class breaks auto completion

Đang mở
#3,327 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
lua
Lĩnh vực
devtools

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.yp.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.

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 = {}:
Image

When ---@class err.Player is removed or commented:

Image

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

Ngôn ngữ chính
Lua
Star
4.4k
Fork
442
Merge trung bình
8 ngày 9 giờ
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của LuaLS/lua-language-server

Tất cả issue của LuaLS/lua-language-server

Issue tương tự

Thêm issue về Lua

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.