LuaLS / LuaLS/lua-language-server

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

未關閉
#3,243 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Lua
星號
4.4k
分支
442
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用包含兩個檔案 lib.lua 和 other.lua 的範例重現重複結果,然後將其與 function lib.func() 形式進行比較。首先追蹤 language server 對表格指派語法的 go-to-definition 處理,並使用提供的記錄檔作為脈絡。指派形式在函式宣告處回傳一個定義結果時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
lua
領域
devtools
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。