Skip to content

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

Merged
weswigham merged 2 commits into
microsoft:masterfrom
weswigham:same-name-files-multiple-projects
Jul 24, 2018
Merged

Lookup files by resolved Path and not by fileName in sourcemapDecoder when querying program#25908
weswigham merged 2 commits into
microsoft:masterfrom
weswigham:same-name-files-multiple-projects

Conversation

@weswigham
Copy link
Copy Markdown
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 a user and mhegazy 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
Comment thread src/harness/fourslash.ts
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
Copy Markdown
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
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants