LuaLS / LuaLS/lua-language-server

Duplicate "go to definition" results when using table assignment syntax in a module

Abierto
#3,243 1 comentario 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Lua
Estrellas
4.4k
Forks
442
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Image
Reproduction steps
  1. Create a project with two files, lib.lua and other.lua, and populate them as follows:

lib.lua:

local lib={}

lib.func = function() end

return lib

other.lua:

local lib = require('lib')

lib.func()
  1. From other.lua, perform a "Go to definition" on func. 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.

  2. Change lib.lua to:

local lib={}

function lib.func() end

return lib
  1. From other.lua, perform a "Go to definition" on func. 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

file_Users_evanjohnson_sandbox_lua-lsp-test.log

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce los resultados duplicados con el ejemplo de los dos archivos lib.lua y other.lua y compáralo después con la forma function lib.func(). Comienza siguiendo el manejo de go-to-definition del servidor de lenguaje para la sintaxis de asignación de tablas y utiliza el archivo de registro proporcionado como contexto. Se considera terminado cuando la forma de asignación devuelve un único resultado de definición en la declaración de la función.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
lua
Área
devtools
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.