-
Notifications
You must be signed in to change notification settings - Fork 507
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
Reconsideration of Dockerfile.* file association #2128
Comments
There were overwhelmingly (about 50x) more people with actual Dockerfiles named "files.associations": {
"dockerfile.go": "go"
} |
I read issue #1907 and I know there are a lot of people use Besides, the pattern |
I saw hundreds of different extension endings on searches in GitHub and in telemetry; it is not sustainable to try to add them case-by-case.
Can you elaborate? How does setting a language association affect other extensions? |
For example, I install |
I see what you mean. Can you try the language association? That should make |
It's a solution for me, but what I want is removing the |
I know it will overclassify Dockerfiles in some cases, like this one, however, this happened only a small fraction as often as underclassifying. From what I saw in telemetry it was about 2% named Due to the limitations of VSCode there's no perfect solution, but manually adding each of the hundreds of variants I saw isn't realistic. We decided that since the workaround (setting a language association) is the same for each, then it was better to do what is right for 98% instead of 2%. |
I think there are other elements we should consider except the number. Let's say I created a But when I created a |
If you really want to cover situations as much as possible, I think it's better to add a |
I'll look into this |
Thank you, |
Ignoring newlines and taking leading whitespace into consideration, Dockerfiles should start with a comment (or a parser directive), an |
I did a small test and added a
But unfortunately, the |
I've done some investigating. The With Some examples that are correctly treated as Dockerfiles, assuming the "Dockerfile.*" association is removed: Dockerfile.test: FROM alpine
# Because the first line matches from alpine
# Because the first line matches
# The language server does warn about lowercase #a leading comment with leading whitespace
FROM alpine
# Because the first line matches # a leading comment with different leading whitespace
FROM alpine
# Because the first line matches #fake=parserdirective
FROM alpine
# Because the first line matches ARG test
FROM alpine
# Because the first line matches ARG #blah--the language server correctly flags this as an error
FROM alpine
# Because the first line matches Dockerfile: using namespace std;
// Because the file name matches "Dockerfile" Some examples that are correctly not treated as Dockerfiles: Dockerfile.py: print('hello world')
# Because the file name matches "*.py" from Python Some examples that are incorrectly not treated as Dockerfiles: Dockerfile.test:
Dockerfile.py: FROM alpine
# Because the file name matches "*.py" from Python @rcjsuen @simpleapples (also @chrisdoherty4 since he originally opened #1907) There are three shortcomings:
What do you all think? I'm a little more concerned about the first shortcoming--it might justify adding back some of the most common Dockerfile.* names. The second and third seem pretty minor to me. |
@bwateratmsft What about cases like
Shell comment syntax is the same as Docker and Python with the |
@bwateratmsft Thank you for your investigating. For the first shorcoming, It seems like there is no better way to solve the problem. But we can add frequently used For a file started with a |
I don't think that's feasible long-term. We found hundreds of values in #1907, a very long tail--so adding the top 10 still leaves hundreds of people out. I'm not yet convinced that |
Given I raised the original ticket I thought I would contribute in brief (and essentially echo @bwateratmsft ). It's nonsensical to revert a change that compliments the significant majority of use-cases because of 1 edge case that can be alleviated with a rename, or an additional configuration line. @simpleapples , you'll probably move on from your current project that uses dockerfile.go and never hit the problem again. |
I know it's hard to be perfect, based on several reasons: So, It makes sense if you insist on remaining changes in #1908, I could set a user-defined file association to avoid the problem. @bwateratmsft Thank you for your trying on this issue. |
I'm going to leave this open for now and keep thinking about it. Perhaps there's some combination of filename pattern, first line pattern, and MIME type that removes the need to compromise. |
Another use case, template generators. I've got a In my settings json I added: {
"files.associations": {
"Dockerfile.ejs.t": "ejs"
}
} But the trouble here is that I can't share this setting with my team. 😕 |
@TigerC10 You can't put it in a |
I opened microsoft/vscode#105590, I think the easiest thing would be if we could add specific exceptions (like |
Another issue is that after a |
Given the upstream microsoft/vscode#105590 is rejected, I'll close this. I think that the best-for-the-most strategy is to keep things as they are now, with |
@segevfiner That sounds like an issue with Visual Studio Code itself. Is there an issue open about this? |
@rcjsuen Couldn't find any, but who knows what's the right keywords to find an existing one |
I have a file named
dockerfile.go
, which is recognised as aDockerfile
because of #1908 .I know this decision has a point #1907 , but I think it's unresonable. When a
Dockerfile
is recognised asUnknown
, nothing will happen. But when ago
file is recoginsed asDockerfile
, VSCode will format it asDockerfile
. (Especially when I chooseFormat on save
, I think it's widely used.). As you can see on the screenshot below.When it happend, I have to revert the code and add a *.go file association. It's a heavier action than just adding a dockerfile associaiton.
So, I think it necessary to remove
Dockerfile.*
file association.The text was updated successfully, but these errors were encountered: