sublimelsp / LSP-vue

Vue support for Sublime's LSP plugin
MIT License
29 stars 3 forks source link

[Windows] Relative imports are not given consistently cased drive letters #83

Closed Bocom closed 4 years ago

Bocom commented 4 years ago

When using relative imports on Windows, the casing of the drive letter causes Vetur to report the following error: File name 'c:/Projekt/temp/lsp-vue-repro/src/App.vue' differs from already included file name 'C:/Projekt/temp/lsp-vue-repro/src/App.vue' only in casing.

The import looks like this: import App from './App.vue'

This happens regardless of TypeScript being used or not. Setting forceConsistentCasingInFileNames to false in tsconfig.json, as suggested in other instances of this error popping up, doesn't seem to be doing much.

The only workaround I've found that works is creating a Sublime Text project and replacing "path": "." with an absolute path with a lowercase drive letter. It works but isn't an ideal solution. In TypeScript projects, using custom paths defined using paths in tsconfig.json doesn't activate this error. Imports using a custom path shows an absolute path with an uppercase drive letter. When using the project workaround, the drive letter is lowercased as well.

This error does not occur in Visual Studio Code.

Minor detail: for some reason, when a .vue file is imported from a .js or .ts file, the error is reported inside the imported .vue file. In this case, it would be reported on line 1 column 1 of App.vue. When importing a .vue file from another .vue file, the error is marked on the import statement's path.

Reproduction repo: https://github.com/Bocom/lsp-vue-repro It's a simple vite project.

To reproduce Add the folder in Sublime Text on Windows. Open the file src/App.vue. There should be an error at 1:1 and 7:24 that's similar to the one at the top of this issue.

System info OS: Windows 10 2004 Sublime Text: version 4090 LSP: st4000-exploration LSP-vue: the latest from Package Control

rchl commented 4 years ago

LSP consistently uses upper-case drive letter which doesn't seem to play well with Typescript server.

  "rootPath": "C:\\workspace\\project",
  "rootUri": "file:///C:/workspace/project",
  "workspaceFolders": [
    {
      "name": "project",
      "uri": "file:///C:/workspace/project"
    }
  ]

VSCode (also it encodes : in URI but I doubt this would be something required by spec since browsers don't do that):

    "rootPath": "c:\\workspace\\project",
    "rootUri": "file:///c%3A/workspace/project",
    "workspaceFolders": [
        {
            "uri": "file:///c%3A/workspace/project",
            "name": "project"
        }
    ]
rchl commented 4 years ago

Interestingly it doesn't reproduce in Typescript server itself so it could be an issue with something in vetur.

rwols commented 4 years ago

Perhaps related: https://github.com/microsoft/language-server-protocol/pull/1019#issuecomment-645881267

rchl commented 4 years ago

Looks like vetur does some custom transformations.

https://github.com/vuejs/vetur/blob/57888255dd4e8bc1e8d729d204834462b2b327d7/server/src/utils/paths.ts#L46-L64

called from here for example:

https://github.com/vuejs/vetur/blob/636ca47d3a13e89e3075fa4495053c264e63aa91/server/src/modes/template/interpolationMode.ts#L94-L97

rchl commented 4 years ago

https://github.com/sublimelsp/LSP-vue/releases/tag/1.1.1 includes the latest version of vetur that includes my fix for this.