Skip to content

Commit

Permalink
Fix issue with "File name X differs from already included" on Windows
Browse files Browse the repository at this point in the history
On Sublime Text (and potentially other clients) the paths passed to
LSP servers on Windows have upper-case drive letter. So either:
 - C:\folder\foo
 or
 - file:///C:/folder/foo

This is problematic with Vetur as it normalizes URI paths received from
the client in notifications and requests like "textDocument/completion",
"textDocument/didChange" etc. It uses getFileFsPath() utility path to
get filesystem path from the URI.

But it doesn't do normalization for the filesystem path received through
"InitializeParams.rootPath" and then uses that path to initialize the
Typescript server. That list (parsedConfig.fileNames in serviceHost.ts)
is later used to lookup files passed through other calls and causes
issues due to there being duplicate path differing only with drive letter.

This issue doesn't reproduce in VSCode as it itself normalizes paths
passed to the server and automatically lower-cases the drive letter.

Fix by normalizing the path passed through InitializeParams.rootPath.

Fixes vuejs#2433
  • Loading branch information
rchl committed Nov 6, 2020
1 parent 1efe1ef commit 8c17d1b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/src/services/vls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { getFileFsPath } from '../utils/paths';
import { getFileFsPath, normalizeFileNameToFsPath } from '../utils/paths';

import {
DidChangeConfigurationParams,
Expand Down Expand Up @@ -104,13 +104,17 @@ export class VLS {
};
}

this.workspacePath = workspacePath;
this.workspacePath = normalizeFileNameToFsPath(workspacePath);

this.vueInfoService.init(this.languageModes);
await this.dependencyService.init(workspacePath, config.vetur.useWorkspaceDependencies, config.typescript.tsdk);
await this.dependencyService.init(
this.workspacePath,
config.vetur.useWorkspaceDependencies,
config.typescript.tsdk
);

await this.languageModes.init(
workspacePath,
this.workspacePath,
{
infoService: this.vueInfoService,
dependencyService: this.dependencyService
Expand Down

0 comments on commit 8c17d1b

Please sign in to comment.