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

Lookup files by resolved Path and not by fileName in sourcemapDecoder when querying program #25908

Merged

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Jul 24, 2018

Since each project has a different program, we were looking for a Source.ts which just so happened to also exist in the current program (different file, same name - ah, the folly of using a relative path as an identifier). Now we lookup using the full path instead of the shorthand fileName.

Fixes #25792 and I believe #25662

@weswigham weswigham requested review from mhegazy and a user July 24, 2018 22:16
@weswigham weswigham changed the title Check if the file returned by the program actually refers to the same file as we intend Lookup files by resolved Path and not by fileName in sourcemapDecoder when querying program Jul 24, 2018
@@ -709,7 +709,7 @@ namespace FourSlash {

ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => {
const marker = this.getMarkerByName(endMarker);
if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) {
if (ts.comparePaths(marker.fileName, definition.fileName, /*ignoreCase*/ true) !== ts.Comparison.EqualTo || marker.position !== definition.textSpan.start) {
Copy link
Member Author

@weswigham weswigham Jul 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to fix the fourslash harness to do case-appropriate comparisons of the paths returned in definition requests, since the fallback cache'd mapped locations are always canonicalized paths and not input-case-like strings (and the fourslash harness assumes case insensitivity).

@mhegazy
Copy link
Contributor

mhegazy commented Jul 24, 2018

Please port to release-3.0 as well.

@weswigham weswigham merged commit 23eb591 into microsoft:master Jul 24, 2018
@weswigham weswigham deleted the same-name-files-multiple-projects branch July 24, 2018 22:44
weswigham added a commit to weswigham/TypeScript that referenced this pull request Jul 24, 2018
…oder when querying program (microsoft#25908)

* Check if the file returned by the program actually refers to the same file as we intend

* Simplify
mhegazy added a commit that referenced this pull request Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants