Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When adding a comment block to the end of a file and hitting "enter" within the code block the files contents are cleared #1490

Closed
muppet9010 opened this issue Aug 22, 2022 · 7 comments
Labels
bug Something isn't working feat/formatter Related to code formatter

Comments

@muppet9010
Copy link

muppet9010 commented Aug 22, 2022

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?

Formatting

Expected Behaviour

That it doesn't clear the files content. No real action is required from the formatter during this action.

Actual Behaviour

That it's clearing the files contents.

Reproduction steps

Have a new file with some content, add a comment block to the end of the file and add a new line within the content block, the file is cleared.

I know its Sumneko as it doesn't happen when I disable the extension. It only started in the last version or 2.

Start with file content:

local x = 1 

Press enter a few times to get some empty lines

Type --[[ and it auto completes the closing ]], leaving the cursor in the middle of the command block.

Press enter to add a new line, with the intention of typing within the comment block. The file is cleared at this point.

Video of the issue occuring.
Code_ayA9affLdN

Additional Notes

No response

Log File

file_c%3A_Home_Projects_Factorio%20Modding_Factorio-JD-Plays.log
service.log

@sumneko sumneko added feat/formatter Related to code formatter bug Something isn't working labels Aug 22, 2022
@sumneko
Copy link
Collaborator

sumneko commented Aug 22, 2022

@CppCXY

@CppCXY
Copy link
Collaborator

CppCXY commented Aug 23, 2022

I can't reproduce, can others reproduce it?
currently you can choose to turn off format on type

@muppet9010
Copy link
Author

ah balls, I forgot I had a Sumneko plugin present.
When I remove the plugin the issue doesn't occur.
Tried with and without the plugin twice and its reproducible. I will raise with the plugin maker.
Sorry.

@CppCXY
Copy link
Collaborator

CppCXY commented Aug 23, 2022

I reproduce this, by install the plugin. maybe the result of 'type on format' is handled by plugin mechanism, or error handling by plugin.

@muppet9010
Copy link
Author

muppet9010 commented Aug 23, 2022

So the plugin creator made a suggestion, which they believe shows its a Sumneko core issue and not a Plugin specific issue.

I added a dummy plugin to my workspace, set the plugin path to this and the issue still occurred.
I confirmed the real plugin wasn't being loaded, as the real plugin changes the scope of a global variable called global to include the workspace name, but in this test the global scope was still just global.

Dummy plugin:

root of workspace\plugin\plugin.lua

function OnSetText()
  return {}
end

Set Sumneko to use this dummy plugin at the workspace settings level:
"Lua.runtime.plugin": "/plugin/plugin.lua"

I close VS Code, make the changes and then open it up clean.

Reproduced issue with this dummy plugin active then used "undo" to return the code back to how it was at the fresh load.
log.zip

If I set my plugin path setting to be empty string "" in my workspace settings (so it overrides my user setting) then I don't see any issue.

@sumneko
Copy link
Collaborator

sumneko commented Sep 6, 2022

I cannot reproduce it, did you triggered formatting?
Please try to disable formatthing/range formating/type formating.

@sumneko
Copy link
Collaborator

sumneko commented Sep 6, 2022

I can reproduce it with range formatting now.

@sumneko sumneko closed this as completed in 66db6ce Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat/formatter Related to code formatter
Projects
None yet
Development

No branches or pull requests

3 participants