microsoft / vscode-docker

Docker Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
Other
1.19k stars 508 forks source link

Highlight is broken in `heredocs` regions of the docker file #4188

Closed romintomasetti closed 1 week ago

romintomasetti commented 6 months ago

When using heredocs sections in a Docker file, this extension does not seem to correctly highlight.

See the below screenshot. The comment is not colorized.

However, other linters I've tried manage to do it correctly. I'll mention https://github.com/hadolint/hadolint for instance.

Is there anything I can do to help you with this?

image

rcjsuen commented 3 months ago

When using heredocs sections in a Docker file, this extension does not seem to correctly highlight.

See the below screenshot. The comment is not colorized.

However, other linters I've tried manage to do it correctly. I'll mention https://github.com/hadolint/hadolint for instance.

@romintomasetti Sorry, could you explain how hadolint provides syntax highlighting? It is a tool for linting Dockerfiles and not about syntax highlighting.

romintomasetti commented 3 months ago
Let's compare the output in VS Code. without this extension with this extension enabled
image image

Basically, the # Command was in green but your extension makes it blue (in my color settings), making the code harder to read.

rcjsuen commented 3 months ago

Basically, the # Command was in green but your extension makes it blue (in my color settings), making the code harder to read.

@romintomasetti That is a (positive) side effect of the # character being the character for comments in a Dockerfile.

FROM alpine
COPY <<EOF test.go
// this is a comment
EOF

If you had the above Dockerfile where // is the character for comments it would not get highlighted.

rcjsuen commented 3 months ago
"[dockerfile]": {
    "editor.semanticHighlighting.enabled": false
}

If you would like to disable semantic highlighting, you can put the snippet above in your settings.json which will put you in the default colouring provided by Visual Studio Code instead of what the language server is calculating.

rcjsuen commented 2 weeks ago

@bwateratmsft I think we can consider this to be a duplicate of #4183.