LuaLS / LuaLS/lua-language-server
Adding ---@class breaks auto completion
Nessuno ha ancora preso questa issue.
- Lingua principale
- Lua
- Stelle
- 4.4k
- Fork
- 442
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema nell’estensione Visual Studio Code usando l’esempio Lua riportato e confronta il completamento con e senza l’annotazione ---@class err.Player. Traccia la gestione del completamento per le annotazioni di classe e verifica che p:set_position(), p.x, p.y e p.happy vengano visualizzati quando l’annotazione è presente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100