Rename Variable and Find All References Finds No Matches

timmaugh 6 Reputation points
2022-02-08T02:25:01.563+00:00

Working in a js file and I've been able (and can in other files) to rename a variable by selecting the variable, right-clicking, and choosing "Rename." I make the change, and the dialog box reports how many places it is going to change in the file. Recently, however, even though the context/scope detection highlights the usage of the variable within the same scope:
JMN4COJ.png
The Rename dialog shows "0 Matches"...
eYUaNib.png
And the "Find All References" function shows nothing... not even the declaration that is in the first image, above:
kDb9LYX.png

I have to think this is something I'm doing, or some setting I have overlooked. This file shows 0 errors (linter errors, but nothing optional/warning stuff; nothing substantial). Is there an easy answer to this?

Developer technologies Visual Studio Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. timmaugh 6 Reputation points
    2022-02-18T21:55:42.787+00:00

    OK, it has something to do with the option to "Open a Folder". I can open the file directly into Visual Studio, enter the "Rename" panel (F2), and see the references that will be affected by any name change.

    However, if I open the containing folder (CTRL + SHFT + ALT + O), and then open the very same file, the Rename functionality is broken.

    I have always worked on this series of files in this same manner (opening the folder), and only recently saw this problematic behavior... so I'm thinking this must have changed with a VS update.

    1 person found this answer helpful.

  2. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2022-02-09T06:56:48.02+00:00

    Hi @timmaugh ,

    Welcome to Microsoft Q&A!

    Which version of Visual Studio are you using? Please create a new project to check if the Rename and Find All References work.

    If it doesn’t work, please update your VS to the latest version in VS installer.
    Meanwhile, you can enter “devenv /ResetSettings” at Developer Command Prompt to restore your Visual Studio default settings and check again.

    Sincerely,
    Anna
    *
    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. timmaugh 6 Reputation points
    2022-02-18T17:02:48.27+00:00

    I deleted the .vs folder, but I saw no option to Build the project (online references say I should see that on my menu, but I don't). I believe that's because I am not working in a Solution but just in a set of unrelated subfolders. I upgraded to VS 2022, now at version 17.1.0 (the latest as of this posting). The problem is also not corrected by whatever solution was rolled into the latest release of VS, as mentioned in the ticket you referenced.

    Any idea what my next step should be?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.