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

Behavior of detecting the file language #101573

Closed
simpleapples opened this issue Jul 2, 2020 · 5 comments
Closed

Behavior of detecting the file language #101573

simpleapples opened this issue Jul 2, 2020 · 5 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@simpleapples
Copy link

simpleapples commented Jul 2, 2020

  • VSCode Version: 1.46.1
  • OS Version: macOS 10.15.5

Steps to Reproduce:

  1. create a file named dockerfile.go, dockerfile.py or other extensions.
  2. you can see the file is detected as a Dockerfile, but it should be a go file or python file.

Screen Shot 2020-07-02 at 3 59 43 PM

Related logic:
I found the file detecting logic is here:

// 1.) Exact name match has second highest prio
if (filenameMatch) {
return filenameMatch.mime;
}
// 2.) Match on pattern
if (patternMatch) {
return patternMatch.mime;
}
// 3.) Match on extension comes next
if (extensionMatch) {
return extensionMatch.mime;
}

Filename Match has the higher priority than Extension Match, I think it should be reconsidered. Extension Match should have the highest priority.

Does this issue occur when all extensions are disabled?: Yes/No
Yes

@bpasero
Copy link
Member

bpasero commented Jul 3, 2020

I can reproduce in Code stable, but not Insiders, but have no clue what has changed.

@simpleapples can you try to reproduce with our insiders?

@bpasero bpasero added the info-needed Issue requires more information from poster label Jul 3, 2020
@simpleapples
Copy link
Author

Hi, @bpasero, thank you for your response.

I can't reproduce the same result on the latest insider build. There is no essential change between insider build and stable build on the file mime.ts.

So I have the same confusion about the different behaviors.

@bpasero
Copy link
Member

bpasero commented Jul 3, 2020

Ok, looks like this got fixed somehow I cannot explain why. We can reopen if this comes back next month after we have released.

@bpasero bpasero closed this as completed Jul 3, 2020
@simpleapples
Copy link
Author

simpleapples commented Jul 6, 2020

I got reasons about this issue.

  1. Why a dockerfile.go is recognized as a Dockerfile?
    Recently, developers of vscode-docker added a Dockerfile.* file association (Add Dockerfile.* file association vscode-docker#1908), If a file is called dockerfile.go, it will match this pattern and will be recognized as a Dockerfile.

  2. Why detection behaviors are different between insider and stable?
    The extension/docker/package.json of vscode is different from extension/docker/package.json of vscode-docker after Add Dockerfile.* file association vscode-docker#1908. So, it will function properly with docker extension installed, whether in insider or in stable.

Next step:
I'm trying to argue with developers of vscode-docker to remove the Dockerfile.* file association (microsoft/vscode-docker#2128), because it will disrupt normal operation of file associaitons of other languages.

Just to explain.

@simpleapples
Copy link
Author

Hi, @bpasero , I'm confused about the mechanism of file type detecting.

As you know, there is a filenameMatch and a extensionMatch. extensionMatch is responsible for checking the extension of files. filenameMatch for the filename.

But, if we add a pattern filename.* on filenameMatch, it can match any extensions. For my perspective, filenameMatch should just match filenames without extension.

What do you think about it ?

@github-actions github-actions bot locked and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants