-
Notifications
You must be signed in to change notification settings - Fork 132
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
Corrupted output from code formatting #793
Comments
@radeksimko I got some time to look into this a while back and these are the findings: For starters, we're actually getting the expected response from
The problem seems to be with how we're converting the diff to changes i.e This is an insertion because, as shown in the image below, we're actually removing the brace in the 5th line and inserting it anew. The brace on the 6th line then automatically falls into its right place. But, again, somehow that insertion overwrites the last not-to-be-touched brace. Not sure if the above seems relevant but If you think it sounds right, I can dig deeper to find a fix for this. Let me know what you think. Thanks |
@timmclean Thanks for the detailed report. I managed to reproduce it using your example above, in the VS Code extension. @danishprakash Thanks for the debugging efforts here and sharing your findings. I'd like to get this fixed in the next release which we pre-emptively planned for the upcoming Thursday, so if you have the time to dig deeper in the next few days that would be great! Otherwise I'd likely pick it up on Tuesday or Wednesday. |
Hey @radeksimko, I might not be able to look at it before next weekend, unfortunately. |
This functionality has been released in v0.27.0 of the language server. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Confirmed fixed. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Server Version
Terraform Version
Client Version
Terraform Configuration Files
testcase.tf
Log Output
Log file
Expected Behavior
Running the LSP code formatter on the current buffer using
:lua vim.lsp.buf.formatting()
should not add syntax errors.Actual Behavior
The code formatter removes a closing brace, causing a syntax error:
Error text:
Unclosed configuration block: There is no closing brace for this block before the end of the file.
Steps to Reproduce
testcase.tf
as above:lua vim.lsp.buf.formatting()
Additional info
When running
terraform fmt
on the same file, the output seems to be correct. I couldn't reproduce the problem usingterraform fmt
.Here is the JSONRPC response to the formatting request:
The text was updated successfully, but these errors were encountered: