chef/vscode-chef

Toggle comments does not work for Chef Metadata file type

dg42xyz opened this issue · 3 comments

Describe the problem

When editing metadata.rb files, they are recognized as a Chef Metadata file type rather than Ruby. However, the ability to toggle comments using the keyboard shortcut CTRL + / does not work in the Chef Metadata file type.

Software Version

VS Code: version 1.40.1
Chef Infra Extension: version 0.8.1
OS: Windows 10 (10.0.17763)

Replication Case

  1. Open a file named metadata.rb. Ensure that it is recognized as a Chef Metadata file type.
  2. Highlight a portion of the file and use CTRL + / to attempt to toggle comments. Notice comments are not toggled.
  3. As a comparison, open a different Ruby file (for example, Policyfile.rb). Perform the same action as step 2, but notice how comments are toggled on/off.

Update: I was able to dig into the VSCode docs a bit and figure out a workaround. Not sure this is the best solution though?

Workaround

  1. Update package.json (in ~/.vscode/extensions/chef-software.chef-0.8.1) to include "configuration": "./chef_metadata_language.json" within the object for the chef_metadata language (under contributes > languages).
  2. Created chef_metadata_language.json file in the same directory as the package file. I kept it simple and just have it as:
    { "comments": { "lineComment": "#", "blockComment": "#" } }
  3. Reloaded VSCode.

This is the documentation I referred to for this change: https://code.visualstudio.com/api/language-extensions/language-configuration-guide

@tas50 Could you have a look at this and see if it makes sense?

tas50 commented

We've fixed this on master and it'll get shipped soon.