forcedotcom / salesforcedx-vscode

Salesforce Extensions for VS Code
https://developer.salesforce.com/tools/vscode
BSD 3-Clause "New" or "Revised" License
940 stars 397 forks source link

Using Rename Symbol (F2) in VSCode renames also part after dot. #5613

Open PawelWozniak opened 1 month ago

PawelWozniak commented 1 month ago

Summary

This is the same area as in https://github.com/forcedotcom/salesforcedx-vscode/issues/5585 When I use Rename Symbol (F2) in VSCode, with Apex class open, then also part after dot is replaced. See example below.

Steps To Reproduce:

  1. Open apex class and paste this code:
    Contract oneChildContract = parentContract.Renewal_Contracts__r.get(0);
    renewalContract.StartDate = oneChildContract.EndDate.addDays(1);
    renewalContract.StartDate = oneChildContract.EndDate;
  2. Use Rename Symbol (F2) on "oneChildContract" and type "firstChildContract". Code will be renamed but too much is renamed.
    Contract firstChildContract = parentContract.Renewal_Contracts__r.get(0);
    renewalContract.StartDate = firstChildContract.firstChildContract.addDays(1);
    renewalContract.StartDate = firstChildContract.EndDate;

    oneChildContract.EndDate.addDays(1); become firstChildContract.firstChildContract.addDays(1);

Word EndDate was replaced by firstChildContract.

In the line below where there is no .addDays() replacement is correct.

Expected result

Word EndDate is not replaced by firstChildContract.

Actual result

Word EndDate was replaced by firstChildContract.

Additional information

Feel free to attach a screenshot.

Salesforce Extension Version in VS Code: 60.13

Salesforce CLI Version: @salesforce/cli/2.42.6 win32-x64 node-v20.12.2

OS and version: Windows 11

VS Code version: 1.89.1

Most recent version of the extensions where this was working:

git2gus[bot] commented 1 month ago

This issue has been linked to a new work item: W-15873777

daphne-sfdc commented 1 month ago

Hi @PawelWozniak, Thank you for filing this issue. Yes, I'm able to replicate it using the code snippet that you provided. I have created a bug in my team's backlog, and we will prioritize it during our grooming session next week.