LuaLS / LuaLS/lua-language-server

Anonymous function whitespace

Open
#2,652 0 comments 1 reaction 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

### How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

### Which OS are you using?

Windows

### What is the issue affecting?

Completion

### Expected Behaviour

Not adding a whitespace character if a function is anonymous and therefore can't have a name.

### Actual Behaviour

Adds a whitespace character like if I were create a regular function, which I can name.

### Reproduction steps

1. Type `table.sort({}, `.
![image](https://github.com/LuaLS/lua-language-server/assets/104660140/c060feb1-5fb5-4dc2-acd5-5ce1e3203cf7)
2. Once it suggests to autocomplete the template function, press Enter.
![image](https://github.com/LuaLS/lua-language-server/assets/104660140/e0f89e34-5191-4e12-8310-4cec41b38cee)

### Additional Notes

I think it's a bug because I've never seen anyone code like that. I couldn't find anything related to this in the settings nor in the documentation.

### Log File

_No response_

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

Reproduce the completion behavior in the Visual Studio Code extension on Windows using `table.sort({}, ` and accept the suggested anonymous function template. Trace the completion handling for anonymous versus regular functions, then verify that accepting the anonymous template does not insert the extra whitespace character.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
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.