-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(language-service): Paths on Windows should be normalized (#40492)
Many `ts.LanguageService` APIs accept a filename, for example ```ts getQuickInfoAtPosition(fileName: string, position: number) ``` The requirement is that `fileName` is agnostic to the platform (Linux, Mac, Windows, etc), and is always normalized to TypeScript's internal `NormalizedPath`. This is evident from the way these APIs are called from the language server: ```ts private onHover(params: lsp.TextDocumentPositionParams) { const lsInfo = this.getLSAndScriptInfo(params.textDocument); if (lsInfo === undefined) { return; } const {languageService, scriptInfo} = lsInfo; const offset = lspPositionToTsPosition(scriptInfo, params.position); const info = languageService.getQuickInfoAtPosition(scriptInfo.fileName, offset); // ... } ``` https://github.com/angular/vscode-ng-language-service/blob/9fca9c66510974c26d5c21b31adb9fa39ac0a38a/server/src/session.ts#L594 Here `scriptInfo.fileName` is always a `ts.server.NormalizedPath`. However, #39917 accidentally leaked the platform-specific paths, and caused a mismatch between the incoming paths and the paths stored in the internal data structure `fileToComponent`. This PR fixes the bug by always normalizing the paths, and updating the type to reflect the format of the underlying data. Fixes angular/vscode-ng-language-service#1063 PR Close #40492
- Loading branch information
1 parent
2731a4b
commit b8e47e2
Showing
2 changed files
with
28 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters