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

[BUG] Conflict with YAML Extension Affecting File Formatting #4196

Closed LisonFan closed 5 months ago

LisonFan commented 6 months ago

Hello,

I've encountered a compatibility issue with the Docker extension when the YAML extension is also installed in VSCode.

Issue Description

Once the YAML extension is installed, the Docker extension (ms-azuretools.vscode-docker) seems to lose its ability to format docker-compose.yaml and Dockerfile. The error message displayed is: "No formatter installed for 'dockerfile/dockercompose' files." This problem arises specifically after the installation of the YAML extension, indicating a potential conflict.

Steps to Reproduce

  1. Install and confirm the functionality of the Docker extension: ms-azuretools.vscode-docker
  2. Install the YAML extension.
  3. Open a docker-compose.yaml or Dockerfile.
  4. Try using the Format Document feature in VSCode to format the file.

Environment

Additional Context

image image image

It appears to be a conflict between the Docker and YAML extensions within VSCode, affecting the file formatting capabilities. Any insights or solutions to resolve this would be greatly appreciated.

Thank you for your assistance in addressing this issue.

bwateratmsft commented 5 months ago

For the compose document, it looks like the YAML language extension is not registering itself as a formatter for documents with the dockercompose language ID. Can you file an issue in their repository for that? It is intentional that the Docker extension disables its own formatter if the YAML extension is installed, because they frankly have a better formatter.

As for the Dockerfiles, you don't have the file saved yet, and it appears that VSCode does not let you format files of some languages until the file has been saved. For example, I was able to format a JSON document before saving the file, but not a Go, Java, or Python file. If you save the document the formatter should work.

bwateratmsft commented 5 months ago

External issue: https://github.com/redhat-developer/vscode-yaml/issues/1000