LuaLS / LuaLS/lua-language-server

Unexpected `textDocument/references` results on keys inside nested tables

未关闭
#1,281 5 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
Lua
星标
4.4k
派生
442
PR 合并指标
30 天内没有已合并 PR

描述

Describe the bug
textDocument/references is returning unexpected results when used in a specific situation (more about that below).

To Reproduce

  1. Paste the following snippet in a lua file
ENUM = {
  VALUE1 = 1,
  VALUE2 = 2,
}

a = {
  { type = ENUM.VALUE1 },
  { type = ENUM.VALUE1 },
  { type = ENUM.VALUE2 },
}
  1. Move cursor over the 1st instance of "type" key in the a table
  2. Request references (textDocument/references)
  3. Observe the faulty results which comprise of the hovered "type" key + both instances of "VALUE1"

Expected behavior
Results that comprise of all 3 instances of "type" key

Additional context
textDocument/rename on the other hand only renames the hovered "type" key while expected to rename all 3 of its instances

Environment

  • OS: Linux
  • Client: Neovim

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用所示的嵌套表示例在 Lua 文件中复现该问题,并针对第一个类型键请求 textDocument/references。将返回的位置与 textDocument/rename 的行为进行比较;当 references 包含全部三个类型键且不包含 VALUE1 或 VALUE2 时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua, neovim
领域
devtools
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。