Skip to content

firstLine MUST not trump exension #2883

Closed

Description

I have a TS file which has a first line like

#!/usr/bin/env node

which is supported by the tsc compiler.

VSCode now treats the ts file as JS which results in very wired behavior.

In general I think first line is content sniffing (like binary detection) and shouldn't overrule extensions.

Activity

  1. added
    bug
    important
    on Feb 10, 2016
  2. dbaeumer commented on Feb 10, 2016

    @dbaeumer
    MemberAuthor

    Benjamin Pasero (@bpasero) I discussed that in length with alexandrudima and Erich Gamma (@egamma) and I understand the history of the change. But the current behavior is very unexpected. The long term solution is for sure to have more extensions handle a file type and let the user decide which one he wants to use. In the short term we might the firstLine rule be combined with an extension. For the shebang we can say that the file must not have an extension to make that rule win.

  3. removed
    important
    on Feb 24, 2016
  4. bpasero commented on Feb 29, 2016

    @bpasero
    Contributor

    Dirk Bäumer (@dbaeumer) Erich Gamma (@egamma) alexandrudima I think my motivation for this change was to support the Flow language case where the extension is JS but a first line header indicates it should be treated by the Flow language service.

    If you guys have an idea how to still support that scenario, please let me know.

  5. bpasero commented on Mar 1, 2016

    @bpasero
    Contributor

    Since you guys seem to found an agreement, please go ahead and make the change in https://github.com/Microsoft/vscode/blob/master/src/vs/base/common/mime.ts#L123 and let me know for review.

  6. bpasero commented on Mar 4, 2016

    @bpasero
    Contributor

    Discussed with Alex and we have an idea how to solve this together with the ability to let the user configure file => language setting.

  7. bpasero commented on Mar 7, 2016

    @bpasero
    Contributor

    The new order is: full filename match, pattern match, extension match, firstline match.

  8. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions