LuaLS / LuaLS/lua-language-server

textDocument/formatting should return a edits instead of totall text for client

Open
#1,049 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement feat/formatter
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
https://github.com/sumneko/lua-language-server/blob/f760dc359b389c20a0d48bef463d14800e67894c/script/core/formatting.lua#L5-L25

As a server, we should diff the document and the return result and generate the edits for the client.
If the server returns totally text result, the context resource in the client may be invalid, like semantic token.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with script/core/formatting.lua, especially lines 5-25, and trace the textDocument/formatting response. Compare the formatted document with the original and follow the issue's requirement to generate edits rather than return the entire text. Done means the client receives edits and its existing context resources remain valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.