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

fix: added flushFilePath() #4240

Merged

Conversation

jeffb-sfdc
Copy link
Contributor

What does this PR do?

There's a bug in VS Code, which Microsoft refuses to fix (see microsoft/vscode#152993). After a file has been renamed, if only the casing has changes (eg no characters added or removed) VS Code passes the stale path to commands. This PR adds flushFilePath() and flushFilePaths() to fix this issue.

What issues does this PR fix or reference?

##3575, @W-10273785@

Functionality Before

  1. Rename an Apex class's file name (only changing the case of the filename), and rename it's metadata file
  2. Open the file and change the name of the class to match
  3. With the file open, right-click in the editor and select "SFDX : Deploy This Source to Org"
  4. This results in an error in the output: "File name mismatch with class name"

Functionality After

1-3: the same
4. This deployment succeeds

@jeffb-sfdc jeffb-sfdc requested a review from a team as a code owner June 28, 2022 21:34
@jeffb-sfdc jeffb-sfdc requested a review from klewis-sfdc June 28, 2022 21:34
// console.log('what are the args', {
// args0: sendExceptionStub.getCalls()[0].args[0],
// args1: sendExceptionStub.getCalls()[0].args[1]
// });
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about either adding a comment here as to why this is no longer applicable or removing entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove them. This was there and was adding noise to the output. salesforcedx-vscode-core has a lot of noise in it when the untegration tests run. When the tests run (either locally, or in CI) there are lots of errors reported, and it's at the point where it's hard to tell when a failure is a failure or not. This is just a "drop in the ocean" and I hope to focus on this at some point and clean up the build.

Copy link
Contributor

@klewis-sfdc klewis-sfdc left a comment

Choose a reason for hiding this comment

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

In QA so far, I can confirm that renaming by changing the casing only and then deploying now works correctly. Nice!

Looking at the changes in the PR, are there delete or retrieve actions that should also be tested here?

@jeffb-sfdc
Copy link
Contributor Author

Looking at the changes in the PR, are there delete or retrieve actions that should also be tested here?

Yes, this fix was also added to forceSourceDelete.ts and LibraryPathsGatherer.ts

And LibraryPathsGatherer is used in fourceSourceDeploySourcePath and fourceSourceRerrieveSourcePath.

Copy link
Contributor

@klewis-sfdc klewis-sfdc 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 to me! Thanks @jeffb-sfdc !

  • SFDX: Deploy Source to Org works after renaming locally by only making changes to the casing in the file/class name
  • SFDX: Deploy Source to Org works when deploying multiple files after renaming one locally by only making changes to the casing in the file/class name
  • SFDX: Retrieve Source from Org works as before
    • Note: If you rename locally, you still need to deploy the class first so that it is renamed on the server before executing a “Retrieve” operation
  • SFDX: Delete from Project and Org works as before
    • Note: Similarly, if you rename the component/class locally, you need to deploy it so that the name is aligned on the server before running a delete operation

@jeffb-sfdc
Copy link
Contributor Author

jeffb-sfdc commented Jun 29, 2022

In QA so far, I can confirm that renaming by changing the casing only and then deploying now works correctly. Nice!

Thanks @klewis-sfdc . Just a heads up - I updated the existing tests and they pass. I'm now adding tests for flushFilePath().

@klewis-sfdc
Copy link
Contributor

Also tested "SFDX: Launch Apex Replay Debugger with Current File" - working as before - looks good! ✅

@jeffb-sfdc jeffb-sfdc merged commit 6b563ec into develop Jun 29, 2022
@jeffb-sfdc jeffb-sfdc deleted the jb/added-flushFilePath-to-fix-stale-uri-after-rename-take-2 branch June 29, 2022 23:47
angela-young pushed a commit that referenced this pull request Jul 7, 2022
* fix: added flushFilePath() to fix the issue where VS Code passes us stale and out of date URIs
@gbockus-sf gbockus-sf restored the jb/added-flushFilePath-to-fix-stale-uri-after-rename-take-2 branch July 8, 2022 15:20
gbockus-sf added a commit that referenced this pull request Jul 8, 2022
gbockus-sf added a commit that referenced this pull request Jul 8, 2022
gbockus-sf added a commit that referenced this pull request Jul 8, 2022
@CristiCanizales CristiCanizales deleted the jb/added-flushFilePath-to-fix-stale-uri-after-rename-take-2 branch August 15, 2023 16:08
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