LuaLS / LuaLS/lua-language-server

Collapsing of functions in the editor breaks if there is a comment before and after the function declaration

Open
#2,581 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

VSCode with sumneko.lua 3.7.4

Reproducer:

```
-- foo
function foo() -- foo
if a then
return a
end
end
```

This code shows two collapsing/folding indicators to the left, one for the if (expected) and one for the comment (unexpected), but none for the function itself:

![Screenshot 2024-03-24 152122](https://github.com/LuaLS/lua-language-server/assets/8938753/2809ab95-b8ec-4d44-bb29-4b47f3e462aa)

Clicking the first folding icon results in this:

![Screenshot 2024-03-24 152938](https://github.com/LuaLS/lua-language-server/assets/8938753/a7ad8d96-75bc-4960-8596-eb077a0bbc47)

It looks like it thinks the two comments belong to one comment block for the function instead of being unrelated comments.

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 by reproducing the folding behavior in VSCode with the supplied Lua example and compare the indicators around the comments, function, and if block. Done means the comments remain separate and the function receives its expected folding indicator without breaking the if folding behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, vscode
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.