LuaLS / LuaLS/lua-language-server

Wrong edit range for param completions

オープン
#3,273 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

test.lua の例と Neovim を使って問題を再現し、my_type|my_type[] 型のパラメータに対する補完の編集範囲に焦点を当てます。引数が波括弧内にある場合に、補完範囲がどのように計算されるかを追跡します。補完を選択すると波括弧内の値だけが置き換えられ、周囲のリスト構文が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua, neovim
領域
developer-experience, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。