vscode-terraform
vscode-terraform copied to clipboard
Toggle Line Comment not working
The "Toggle Line Comment" editor.action.commentLine is broken. (key combo in MacOS: cmd /)
It works with other formats (yaml, json, c++, shell, etc) but its not (no longer?) working with Terraform files.
VSCode Terraform Plugin Version: 2.2.2
I'm encountering this issue with v2.2.2 as well. I rolled my extension back to v2.2.1 and "Toggle Line Comment" starts functioning again, so the problem appears to have been introduced with v2.2.2
VSCode 1.48.1 MacOS 10.15.2
Hi! Sorry you're seeing this behavior. We're having trouble reproducing it with a default configuration – could you share your settings files?
Hmmm, I reinstalled v2.2.2 just now and the issue appears to have resolved itself! @Helmut-Onna does the issue still occur for you?
Hi, it is fixed now, close if you want.
But please note I had to follow the "downgrade-upgrade version" steps similar to what Eric described since my first attempt to install it "from cero" didn't worked: 1- uninstal extension/plugin (vscode will restart/refresh) 2- install latest (v2.2.2) terraform plugin/extension, 3- try a TF file, not working 4- downgrade to extension v2.2.1 (vscode restarts/refreshes itself) 5- confirmed, toggle comments work 6- upgrade to v2.2.2 (vscode restarts/refreshes itself) 7- try again toggle comment line in a TF file, it works!
Maybe it was a leftover from my previous upgrade/downgrade attempts when the highlighting was broken in v2.1.1+ (went down in versions one by one to 2.1.0 since highlighting was working on that one)
Anyway, thanks a lot for the help, specially to Eric since without that downgrade step I guess I would had required to reinstall vscode fully :)
I just experienced the issue again, immediately after updating the language server. The same downgrade-then-upgrade approach resolved the issue, but I'm curious about why the LS update caused the issue.
May have been related, also seemed to involve terraform, would suggest whatever bug this is (whether be in the plugin, or upstream vscode) it has maybe been around since May: https://github.com/microsoft/vscode/issues/98110
Hi @ericmacfarland – would you be willing to file a bug upstream on the VSCode project? We'll keep looking for something on our end as well.
Uninstalling and reinstalling fresh worked for me.
I was very close to completely ditching this plugin before I found this GitHub issue. Thanks @ericmacfarland for your suggestion.
Also facing this issue from time to time. Just found out that simple Disable-(Reload)-Enable the Terraform plugin helps.
none of disable-reload-enable or reinstalling or downgrade/upgrade worked for me.
only seems to be terraform files for me. other files work fine.

extension version 2.5.0
This issue is still present, but I discovered an odd workaround for it earlier today. If you install the HCL extension, you'll get the ability to comment back but it will be with // rather than #. You'll notice at this point that your tf files show as type "HCL" in the bottom right.
If you change the file type back to "Terraform", the old commenting shortcut works again and uses # like before.
No idea why this works, but it does. If you uninstall the HCL extension, the shortcut stops working again.
Same issue here
Once I updated to VS 1.55.2 ctrl + / started working for me.
can confirm that vscode Version: 1.56.2 (Version: 1.56.2 on OS: Darwin x64 18.7.0 ) with hashicorp.terraform extension (v2.11.0) it also stopped working after upgrading language server.
I didn't need to downgrade, just uninstall and install the extension again, and block comment (cmd+/) started to work again.
Disable/enable the plugin was enough for me
Disable/enable the plugin was enough for me
same
I just encountered this problem. A reinstall worked fine using the developer tools to reinstall extensions.
Same issue here. Switching back to 4ops.terraform fixes the toggle issue
Hi folks,
It is known that VS Code unfortunately doesn't always handle conflicts well when multiple extensions claim the same file type and there some possibility that this problem may be caused by a combination of particular extensions which all claim *.tf files.
If you have any other extensions supporting Terraform files - have you tried disabling those - if yes - were you still able to reproduce this?
We plan to investigate these conflicts also as part of #692
Can anyone reproduce the issue on the latest version (2.14.0) with the latest LS version (0.19.0) and with all other Terraform extensions (if any are installed) disabled? If so I'd be interested in setting up a debugging session with you or gathering more details.
@radeksimko Can confirm that deleting another Terraform plugin and restarting VSCode fixes the issue. That another extension was just installed and disabled, but it seems it still was causing the conflict. VSCode version: 1.59.0 HashiCorp Terraform: v2.14.0
I updated #692 with a setting you can configure to instruct VS Code which extension handles which language type. This can alleviate having multiple extensions that register for the same language type.
This has happened to me twice now. First time I disabled, reloaded, and enabled the HashiCorp Terraform extension and that fixed it. 2nd time that wouldn't fix it, I downgraded, reloaded, upgraded, reloaded, and that fixed it. I'm on VS Code 1.63.1 & TF extension 2.17.0
I am also having the issue. Works good in tf files, doesn't work in tfvars.
Broken again with vscode 1.65.0. Edit: actually it's Ansible extension.
@Sispheor do you mind providing a link to that extension? I'd just like to understand why would an Ansible extension cause a problem for Terraform files. Usually the conflicts we have seen were between extensions that claim the same file extensions or same language IDs.
No no I meant that the issue doesn't come from this repo. It's the official Red Hat Ansible plugin.
As discussed this is most likely caused by another extension, or rather conflict between different extensions, which is VS Code's (upstream) issue.
We do track more high-level efforts in this area as part of https://github.com/hashicorp/vscode-terraform/issues/692
If folks are aware of a specific extension which causes this issue we'd appreciate a comment in https://github.com/hashicorp/vscode-terraform/issues/692
Aside from that there's not much we can do within this extension unfortunately.
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 details necessary to investigate further.