First off, thank you for the EmmyLua extension and language server!
On my system (Zed 0.225.13 Flatpak on Linux), saving a Lua file can sometimes unexpectedly alter the code after an undo operation. In some cases, lines may be removed, duplicated, or previously deleted code may reappear.
Below is a minimal example where the issue is reproducible.
Tested with default Zed and EmmyLua configuration:
- only HTML and EmmyLua extensions installed in Zed
- empty settings.json in Zed
- no .emmyrc.json, .luarc.json, editor.config or EmmyLua-specific settings
Also tested with today's Zed 0.226.4 version.
Steps to reproduce
- Type the following Lua code in a new file
if true then
print(1)
end
print(2)
- Save as a .lua file and ensure that the EmmyLua language server is running
- Select and delete the
if block
- Save the file: the EmmyLuaCodeStyle formatter removes the leading empty lines
- Press Undo twice, to first restore the empty lines then the
if block
- Save the file again
Expected behaviour
Saving should not modify the code, as there is nothing left to format.
Actual behavior
The if statement is removed after saving.

With additional edits, saves, and undo operations, the print(2) line ended up being duplicated and a previously deleted if block reappeared, however I could not yet found a reliable way to reproduce those cases consistently.
I suspect that this might be related to EmmyLuaCodeStyle, but I was unable to reproduce similar issues when using the LuaLS extension with the integrated EmmyLuaCodeStyle enabled.
First off, thank you for the EmmyLua extension and language server!
On my system (Zed 0.225.13 Flatpak on Linux), saving a Lua file can sometimes unexpectedly alter the code after an undo operation. In some cases, lines may be removed, duplicated, or previously deleted code may reappear.
Below is a minimal example where the issue is reproducible.
Tested with default Zed and EmmyLua configuration:
Also tested with today's Zed 0.226.4 version.
Steps to reproduce
ifblockifblockExpected behaviour
Saving should not modify the code, as there is nothing left to format.
Actual behavior
The

ifstatement is removed after saving.With additional edits, saves, and undo operations, the
print(2)line ended up being duplicated and a previously deletedifblock reappeared, however I could not yet found a reliable way to reproduce those cases consistently.I suspect that this might be related to EmmyLuaCodeStyle, but I was unable to reproduce similar issues when using the LuaLS extension with the integrated EmmyLuaCodeStyle enabled.