LuaLS / LuaLS/lua-language-server
"Save as" can cause "duplicate defined alias"
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?
Annotations
### Expected Behaviour
"Save as" should clear the cached aliases from the previous file (in the case of no workspace/folder)
### Actual Behaviour
With a new window with no workspace, when I used "save as" I noticed the aliases from the file were still being used, causing a conflict _duplicate defined alias_ with the newly named file. See repro steps.

### Reproduction steps
0. Start with a new window, no workspace, etc
1. Create a new file, e.g., "test.lua"
2. Add some code and save the file ( `--@alias id integer\n` )
3. "Save as" test_2.lua
4. (Optional) You may need to repeatedly "Save as" (e.g., test_3.lua) to trigger the bug, I couldn't 100% repro
5. Observe _Duplicate defined alias `id`_
Reload editor to clear error
### Additional Notes
This is an edge case, as typically you'd have an workspace or folder open (in which case 'save as' should keep the previous file cached also).
### Log File
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by reproducing the issue in the Visual Studio Code extension with a new window and no workspace, then trace the Save as handling and cached annotation aliases. Done means repeated Save as operations no longer report a duplicate defined alias, while preserving the stated workspace 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
- 42/100