LuaLS / LuaLS/lua-language-server

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

Offen
#1,281 5 Kommentare 1 Reaktion 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

**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
```lua
ENUM = {
VALUE1 = 1,
VALUE2 = 2,
}

a = {
{ type = ENUM.VALUE1 },
{ type = ENUM.VALUE1 },
{ type = ENUM.VALUE2 },
}
```
2. Move cursor over the 1st instance of `"type"` key in the `a` table
3. Request references (`textDocument/references`)
4. 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

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

Reproduzieren Sie das Problem in einer Lua-Datei mit dem gezeigten Beispiel einer verschachtelten Tabelle und fordern Sie textDocument/references für den ersten Typschlüssel an. Vergleichen Sie die zurückgegebenen Positionen mit dem Verhalten von textDocument/rename; abgeschlossen ist die Aufgabe, wenn die Referenzen alle drei Typschlüssel enthalten, ohne VALUE1 oder VALUE2 einzuschließen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
lua, neovim
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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