Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoformatting breaks Dockerfile with heredoc #3327

Closed
wedi opened this issue Nov 20, 2021 · 6 comments · Fixed by #3355
Closed

Autoformatting breaks Dockerfile with heredoc #3327

wedi opened this issue Nov 20, 2021 · 6 comments · Fixed by #3355

Comments

@wedi
Copy link

wedi commented Nov 20, 2021

Using the new heredoc syntax in Dockerfiles used to trigger error messages in VS Code but autoformatting did not interfere with it. Unfortunately this has changed (unfortunately I cannot tell when): since some time autoformatting indents the end marker and following lines which makes it impossible to use autoformatting on save.

This dockerfile

# syntax=docker/dockerfile:1.3-labs
FROM alpine
RUN <<EOF
    echo "Heredocs! Finally!"
EOF
CMD ["sh", "-c", "sleep 5"]

becomes

# syntax=docker/dockerfile:1.3-labs
FROM alpine
RUN <<EOF
    echo "Heredocs! Finally!"
    EOF
    CMD ["sh", "-c", "sleep 5"]

after formatting.

@rcjsuen
Copy link
Contributor

rcjsuen commented Nov 20, 2021

@wedi Thanks for the bug report.

For a workaround, you can set the "docker.languageserver.formatter.ignoreMultilineInstructions" preference to true. See #2976.

@wedi
Copy link
Author

wedi commented Nov 22, 2021

Thanks! I definitely prefer fixing multiline commands myself over fixing the dockerfile in an external editor. :)

@bwateratmsft
Copy link
Collaborator

@rcjsuen do you want to create an issue in https://github.com/rcjsuen/dockerfile-language-server-nodejs for this? Or keep it here?

@rcjsuen
Copy link
Contributor

rcjsuen commented Dec 2, 2021

@rcjsuen do you want to create an issue in https://github.com/rcjsuen/dockerfile-language-server-nodejs for this?

I've opened rcjsuen/dockerfile-utils#105 to track this.

@bwateratmsft
Copy link
Collaborator

Sounds good. Since there's a workaround and we pick up the latest language server regularly I'll close this one.

@bwateratmsft
Copy link
Collaborator

This is now released in Docker extension version 1.19.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants