LuaLS / LuaLS/lua-language-server
Duplicate "go to definition" results when using table assignment syntax in a module
Dieses Issue hat noch niemand übernommen.
- 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?
Kakoune
Which OS are you using?
MacOS
What is the issue affecting?
Other
Expected Behaviour
When a module is written by assigning functions to table members with the following syntax:
local lib={}
lib.func = function()
-- ...
end
return lib
Performing a "Go to definition" on this function from another file that requires the module should go to the function defintion.
Actual Behaviour
Instead when doing a "Go to defintion", there are 2 results, and the user must choose one. They both point to the same line, one points to the table member's name and the other to the start of the function declaration.
Reproduction steps
- Create a project with two files,
lib.luaandother.lua, and populate them as follows:
lib.lua:
local lib={}
lib.func = function() end
return lib
other.lua:
local lib = require('lib')
lib.func()
-
From
other.lua, perform a "Go to definition" onfunc. Note that it has two results that must be chosen, one will take you to the table member's name, and the other will take you to the start of the function declaration. -
Change
lib.luato:
local lib={}
function lib.func() end
return lib
- From
other.lua, perform a "Go to definition" onfunc. It takes you directly to the start of the function declaration (which is also the table member's name).
Additional Notes
I know that the function lib.func() syntax is preferred, but this is an issue for me when using libraries that use the lib.func = function() syntax. I wasn't able to find any discussions of this issue, but it seems likely that others have run into it, so I am wondering if there is a solution that I just haven't found.
Log File
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere die doppelten Ergebnisse mit dem Beispiel aus den zwei Dateien lib.lua und other.lua und vergleiche es anschließend mit der Form function lib.func(). Beginne damit, die go-to-definition-Verarbeitung des Language Servers für die Syntax von Tabellenzuweisungen nachzuverfolgen, und verwende die bereitgestellte Logdatei als Kontext. Als erledigt gilt die Aufgabe, wenn die Zuweisungsform an der Funktionsdeklaration genau ein Definitionsergebnis zurückgibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- lua
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100