editor.formatOnSave is not working as expected
See original GitHub issueHey buddy!
First of all, congratulations for the extension! There’s only one thing that I suggest you to check, it’s the editor.formatOnSave. It’s not working as expected.
The file changed is ignored when saved. On the other hand, when we use Format Document command on VSCode, the file is correctly formatted.
vscode-terraform version: 1.3.12 Terraform version: 0.12.3 VSCode version 1.36.0
settings.json on VSCode
"files.associations": {
"*.ctmpl": "hcl",
"*.tf": "terraform",
"*.tfvars": "terraform"
},
"[terraform]": {
"editor.formatOnSave": true
}
Save file log:
2019-07-10 14:44:26:223 [INFO ] formatting-provider: running 'terraform fmt' on 'c:\Users\MyUser\Desktop\terraform_folder\terraformfile.tf'
2019-07-10 14:44:26:223 [INFO ] runner: Running terraform cwd='C:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code' path='terraform' (version: 0.12.3) args=[fmt, -]
2019-07-10 14:44:27:041 [DEBUG] index-adapter: Ignoring document: file:///c%3A/Users/MyUser/Desktop/terraform_folder/terraformfile.tf
2019-07-10 14:44:32:349 [INFO ] runner: Running terraform succeeded.
Manual Alt Shift F (Format Document):
2019-07-10 14:54:50:445 [INFO ] formatting-provider: running 'terraform fmt' on 'c:\Users\MyUser\Desktop\terraform_folder\terraformfile.tf'
2019-07-10 14:54:50:445 [INFO ] runner: Running terraform cwd='C:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code' path='terraform' (version: 0.12.3) args=[fmt, -]
2019-07-10 14:54:56:071 [INFO ] runner: Running terraform succeeded.
2019-07-10 14:54:56:089 [DEBUG] index-adapter: Ignoring document: file:///c%3A/Users/MyUser/Desktop/terraform_folder/terraformfile.tf
Could you kindly check this please?
Thank you.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Format on Save (prettier) stopped working with latest update
Same thing happened to me just now. I set prettier as the Default Formatter in Settings and it started working again. My Default...
Read more >Why does Prettier not format code in VS Code? - Stack Overflow
Click on Preferences: Open Settings (JSON) from the suggestion dropdown. Inside the settings.json file, Check if "[html]" key exists. If the key ...
Read more >How to enable auto format on save with prettier in VS Code ...
Explainer video about How to enable auto format on save in VS Code (Visual Studio Code) editor with prettier code formatter extension on...
Read more >How to fix Prettier Extension not working issue in VS CODE
How to fix Prettier Extension not working issue in VS CODE. ... How to enable auto format on save with prettier in VS...
Read more >prettier not working vscode Code Example
check "format on Save": Setting >> User >> Text Editor >> Formatting choose prettier as "default ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was experiencing the same issue starting with the latest update in vscode in which they changed the integration with prettier formater. My proposed solution assumes you also have prettier plugin istalled or any other formater as default.
My
settings.json
is configured as follows:With the last part, which overrides the formater for terraform language, my formating started to work again 😃
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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.