panoply / vscode-liquid

💧Liquid language support for VS Code
https://marketplace.visualstudio.com/items?itemName=sissel.shopify-liquid
Other
173 stars 22 forks source link

Comments only being added with opening tags #102

Closed davidwarrington closed 2 years ago

davidwarrington commented 2 years ago

First off - congratulations on getting this over the line!

Onto the issue:

Using the shortcut cmd + / to create a liquid comment, only the opening tag is added to the beginning of each the area.

https://user-images.githubusercontent.com/9138568/192863429-c833c119-5292-4cd1-bb26-31c055f40138.mov

It's happening in every file I try, but in case it helps, here's the code I'm testing in the video

<div class="prg-ProgressBar {%- if value >= max %} prg-ProgressBar-complete{%- endif -%}" style="--ProgressBar_Max: {{ max }}; --ProgressBar_Value: {{ value }};">
  <p class="prg-ProgressBar_Label fz-14_171">
    {%- if value >= max -%}
      <span class="prg-ProgressBar_Icon">
        {%- render 'icon-check' -%}
      </span>
    {%- endif -%}

    {{ label }}
  </p>

  <div class="prg-ProgressBar_Bar"></div>
</div>
panoply commented 2 years ago

Thanks for all the help and discussions to get it/us here!

I've actually never used this command. I will need to have a look and see what might be causing it. I am about to publish a patch, tell me it works. I was using a matching prefix in snippets, but I am not sure if they are related to this?

panoply commented 2 years ago

@davidwarrington can you see if the patch release #103 fixes this?

davidwarrington commented 2 years ago

That update doesn't seem to do it.

I've had a quick scan of the project files and stumbled across this in liquid.language-configuration.json which I think is the cause:

{
    "comments": {
        "lineComment": "{% #",
        "blockComment": [
            "{%- comment -%}",
            "{%- endcomment -%}",
            "{% comment %}",
            "{% endcomment %}"
        ]
    },
    // ...
}

I know very little about VSCode extensions so I'm hoping I'm wrong, or that there is a workaround, but from a very quick scan it looks like lineComment doesn't support > 1 entry. Also I guess technically the line comment you're using here is still a block comment as it doesn't force the entire line to become a comment.

I've tried modifying my install of this extension by removing lineComment and reducing the blockComment option to two items such as below which seems to work, however it I'm not sure why removing lineComment is necessary when a multiline block is highlighted. Also doing something like below would be enforcing either a whitespace-controlled or no-whitespace-controlled opinion.

{
    "comments": {
        "blockComment": [
            "{%- comment -%}",
            "{%- endcomment -%}",
        ]
    },
}

Also just on a personal level I'd really love to default to the inline comments but it's more hassle than it's usually worth if my editor isn't automating writing it for me for multiline comments.

Having a quick Google I also see there's this issue microsoft/vscode#64659 I can see there is some demand for more flexibility here, but no responses.

panoply commented 2 years ago

That's the one. I'll PR

panoply commented 2 years ago

🚢 v3.0.2