LuaLS / LuaLS/lua-language-server

Wrong edit range for param completions

Aperta
#3,273 1 commento 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Lua
Stelle
4.4k
Fork
442
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Completion

Expected Behaviour

For parameters that can either be a single value or a list T|T[], when already in a table, the completion range should not include surrounding curly braces.

Actual Behaviour

The completion edit range provided by lua-language-server for parameters seems to always include the entire parameter, which causes issues when completing params that can be either a single value or a list, for example, T|T[].

Reproduction steps
  1. Create test.lua in the test dir with the following content:
    ---@alias my_type 'a'|'b'
    
    ---@param arg my_type|my_type[]
    local function test_func(arg)
      return arg
    end
    
  2. Use neovim to edit test.lua
  3. Try to call test_func at the end of the file with a list parameter: test_func({ ... })
  4. Completions provided by lua-language-server are shown inside the curly braces
  5. Selecting one of the completions replaces the whole parameter, including the surrounding curly braces.

https://github.com/user-attachments/assets/d69214e9-b069-4554-b4ab-770e2fb50632

Additional Notes

I have also reported to the blink.cmp but the maintainer thinks that it is a lua-language-server's issue: https://github.com/Saghen/blink.cmp/issues/2179

Log File

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema usando l’esempio test.lua e Neovim, concentrandoti sugli intervalli di modifica del completamento per un parametro tipizzato come my_type|my_type[]. Traccia il modo in cui viene calcolato l’intervallo di completamento quando l’argomento si trova all’interno di parentesi graffe. Il lavoro è completato quando la selezione di un completamento sostituisce solo il valore all’interno delle parentesi graffe e preserva la sintassi della lista circostante.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
lua, neovim
Ambito
developer-experience, tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
58/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.