Skip to content

getEditsForFileRename: Handle old file still being present#24328

Merged
mhegazy merged 2 commits intomasterfrom
getEditsForFileRename_oldFileStillPresent
May 23, 2018
Merged

getEditsForFileRename: Handle old file still being present#24328
mhegazy merged 2 commits intomasterfrom
getEditsForFileRename_oldFileStillPresent

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented May 22, 2018

@mjbvz Mentioned having issues with this -- one possibility is that we don't update the program soon enough. This PR would make getEditsForFileRename work even if the program still contains the old file.

@mjbvz Please test this out.

@ghost ghost requested review from mjbvz and sheetalkamat May 22, 2018 19:22
Comment thread src/services/getEditsForFileRename.ts Outdated
: program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName);
if (resolved && contains(resolved.failedLookupLocations, oldFilePath)) {
// We may or may not have picked up on the file being renamed, so maybe successfully resolved to oldFilePath, or maybe that's in failedLookupLocations
if (resolved && contains([resolved.resolvedModule && resolved.resolvedModule.resolvedFileName, ...resolved.failedLookupLocations], oldFilePath)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would have you rather check resolvedModule.resolvedFileName separately and failedLookups separately to ensure not creating duplicate array just to check if it has the value.

Copy link
Copy Markdown
Contributor

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

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

Looks good. I wasn't able to repro the issue using this build.

Thanks!

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented May 23, 2018

@Andy-MS please port to release-2.9

@mhegazy mhegazy merged commit dd6dc5e into master May 23, 2018
@mhegazy mhegazy deleted the getEditsForFileRename_oldFileStillPresent branch May 23, 2018 23:16
@mhegazy mhegazy mentioned this pull request May 23, 2018
mhegazy added a commit that referenced this pull request May 23, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
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.

3 participants