LuaLS / LuaLS/lua-language-server

Autocompletion is not offered for a parameter with a `@class` type

Offen
#1,439 23 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement
Vorherrschende Sprache
Lua
Sterne
4.4k
Forks
442
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

When using a defined class as the type for a parameter, the fields of that table should be offered as an autocompletion when calling the function.

For an example, using @alias works like so:
image

Actual Behaviour

No autocompletion is automatically offered when using @class as the type for a parameter. If you press CTRL + Space, you can make the completions appear, but they will not appear automatically.

Nothing is offered:
image
Until I press CTRL + Space:
image

Reproduction steps
  1. Use the below code:
    ---@class Options
    ---@field page number
    ---@field active boolean
    
    ---@param opts Options
    local function acceptOptions(opts) end
    
    acceptOptions()
    
  2. Move your cursor to line 9 (acceptOptions()) and place it between the parentheses
    image
  3. Enter { to start a table literal
  4. No completions are offered
  5. Press CTRL + Space and notice that the first 2 options are actually proper completions from the Options class. These should automatically be offered.
Additional Notes

No response

Log File

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

In der Issue wird keine Quelldatei oder kein Test genannt. Beginne damit, die bereitgestellte Lua-Reproduktion in der VS Code-Erweiterung auszuführen, und verfolge das Vervollständigungsverhalten, nachdem du { für den Parameter Options eingegeben hast; abgeschlossen ist die Aufgabe, wenn die @class-Felder automatisch angeboten werden, ohne Ctrl+Space zu drücken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
lua
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.