none
Why is Search / Replace so profoundly broken

    Question

  • https://social.msdn.microsoft.com/Forums/vstudio/en-US/450f45c1-cbe7-4f5a-8af7-69ed04c1a572/search-and-replace-across-solution-searches-same-file-multiple-times-before-moving-to-next-file?forum=visualstudiogeneral#450f45c1-cbe7-4f5a-8af7-69ed04c1a572

    The issue cited above exists in VS 2013 specifically but has also existed in every version VS I can remember using .

    This new issue in VS 2015 (have not tested for it in VS 2013) is EVEN BETTER:

    Search for "OldValue" and replace it with "OldValue.NewValue" in current project.
    VS finds an instance of OldValue. 
    Click replace.
    VS finds "OldValue" again but the instance it finds is the instance you just replaced (OldValue.NewValue). 
    Click Find Next.
    VS finds an instance of OldValue. 
    Click replace.
    VS finds "OldValue" again but the instance it finds is the instance you just replaced (OldValue.NewValue). 
    Click Find Next.
    VS finds "OldValue" again but the instance it finds is the prior instance you just replaced (OldValue.NewValue). 
    Click Find Next.
    VS finds an instance of OldValue. 
    Click replace.
    VS finds "OldValue" again but the instance it finds is the instance you just replaced (OldValue.NewValue). 
    Click Find Next.
    VS finds "OldValue" again but the instance it finds is the prior instance you just replaced (OldValue.NewValue). 
    Click Find Next.
    VS finds "OldValue" again but the instance it finds is the first instance you just replaced (OldValue.NewValue). 
    Shoot yourself.

    Thursday, January 28, 2016 4:51 PM

Answers

All replies

  • Of course this issue is long known and I need not explain it further... I just think it is shameful that I have to resort to opening files manually searching and manually typing replacement text.  Really embarrassing Microsoft, for a tool as sophisticated as Visual Studio.  This has been an issue for YEARS now, please fix it.
    Friday, January 22, 2016 9:40 PM
  • Thanks for your feedback, SWheaties:)

    To really repro this issue in our side, would you mind sharing us a simple sample using one drive?

    Please also tell us the VS version you use, so we could setup the same Environment as yours.

    If I could repro this issue, I will help you submit a feedback to the product team.

    As far as I know, the latest VS version was the VS2015 with update 1. So if you use old VS version, you could test it using the latest VS version, so we could know that whether the latest VS still has this issue.

    But if you make sure that the VS2015 still has this issue now, you can also submit this feedback to Microsoft Connect feedback portal: http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx,Microsoft engineers will evaluate them seriously.

    If there's any concern, please feel free to let me know.

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 25, 2016 11:12 AM
    Moderator
  • Jack did you spend five minutes attempting to reproduce the issue as described in the title?

    In ANY version of VS?

    What result did you observe?

    Thursday, January 28, 2016 4:59 PM
  • This new issue in VS 2015 (have not tested for it in VS 2013) is EVEN BETTER:

    Search for "OldValue" and replace it with "OldValue.NewValue" in current project.
    VS finds an instance of OldValue.  Click replace.
    VS finds "OldValue" again but the instance it finds is the instance you just replaced (OldValue.NewValue). 

    It doesn't do that for me - it moves to the next occurrence.

    Do you have some 3'rd party add-in tool installed that may be
    interfering with normal behaviour?

    What sort of project are you working on where you get this behaviour?

    Dave

    Thursday, January 28, 2016 5:51 PM
  • I am a contractor - this installation is a computer on a client site.

    There are no add-ons that I know of (namely resharper is not installed and never has been as far as I know).

    I just tested the behavior again a new console app:

    Create a solution named ConsoleApplication1.

    Add Class1, Class2, Class3, Class4

    Close all files

    Open Program.cs

    Ctrl+Shift +H

    Find "ConsoleApplication1" replace with "ConsoleApplication1.New" 

    ConsoleApplication1 is replaced in Program.cs

    Next find is "ConsoleApplication1.New" in Program.cs.  "ConsoleApplication" is highlighted.

    Click Find Next

    ConsoleApplication1 is found in Class1

    Click replace

    Next find is "ConsoleApplication1.New" in Program.cs.  "ConsoleApplication" is highlighted.

    Click find next

    Next find is "ConsoleApplication1.New" in Class1.cs.  "ConsoleApplication" is highlighted.

    I think you should get it from here.


    • Edited by SWheaties Thursday, January 28, 2016 9:02 PM
    Thursday, January 28, 2016 8:48 PM
  • I just repeated the steps in post below on my own personal laptop using VS 2013 Community.

    Exact same behavior as described in my previous post.  No tools or add ons have ever been installed. 

    As I said in the post I linked too this bug (and/or variations thereof) have been around for years.  Kind of like the bug where text remains highlighted after you search/replace within a selection.  You have to reboot to keep the mouse from selecting text when you move it.  Bet you guys haven't heard of that one either.  But its still young - only been around for ten years or so.


    • Edited by SWheaties Thursday, January 28, 2016 9:01 PM
    Thursday, January 28, 2016 9:00 PM
  • I just tested the behavior again a new console app:

    I think you should get it from here.

    Nope, afraid not. I don't see any such problem with VS2015 update 1.

    It goes through each file in the project as I'd hope it would and when
    it's got to the end I get the "No more occurrences found in the
    specified documents" message box.

    I assume you created a C# console application?

    Dave

    Thursday, January 28, 2016 10:20 PM
  • >I assume you created a C# console application?

    Yes

    Friday, January 29, 2016 1:18 AM
  • I made a screen capture video showing search/replace finding the text it just replaced and also finding (again) in files it has already searched before moving to new files (makes search/replace completely useless when selectively replacing).

    It is anyone's for the asking (just over 3mb).

    Friday, January 29, 2016 1:49 AM
  • Hi SWheaties,

    Thanks for your friendly response.

    Actually I want to know that whether I use the same steps as yours.

    For example, I use a simple app, and then I add a new project using the same code in the same Solution, and then I use the "Find and Replace" function like the following screen shot.

    If I click "Replace", it would work normally in the two .cs files. After it finished replacing in the Program.cs file, it would replace the Class1.cs file one by one, but I didn't get the result as you said that it would search the program.cs or Class1.cs file a few times.

    I just use the VS2013 with update 5 in my side.

    If I have misunderstood this issue, please feel free to let me know.

    Update:

    If we use the same steps, but just your project has this issue in your side, if possible, you could share us a simple sample using one drive, we will test the same project code as yours using the same VS Environment.

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, January 29, 2016 6:58 AM
    Moderator
  • >It is anyone's for the asking (just over 3mb).

    Stick it somewhere (onedrive, youtube, wherever) and post a link to
    it.

    Dave

    Friday, January 29, 2016 8:50 AM
  • Jack I think I may have omitted an important step - I do this out of habit so I did not even think of it.  When I go to search for something I usually double click the word so it is highlighted.  Then I hit Ctrl+shift+H and the word is in the find box.  This may help reproduce the issue.  This is what I did in my screen cap.
    Friday, January 29, 2016 2:36 PM
  • >Try this:

    Flash format - don't have anything to play that anymore :)

    Dave

    Friday, January 29, 2016 2:55 PM
  • LOL I think if I stood in Nadellas office and projected it on the wall it wouldn't do me a bit of good. Did you try to highlight the search text before searching as I mentioned?

    Friday, January 29, 2016 3:33 PM
  • LOL I think if I stood in Nadellas office and projected it on the wall it wouldn't do me a bit of good.

    Probably not :)

     Did you try to highlight the search text before searching as I mentioned?

    I did, and depending on what buttons I pressed, I could get the first
    occurrence to repeat the replacement but no others, I wanted to see
    your video to see if it clarified things.

    Dave

    Friday, January 29, 2016 4:51 PM
  • >> I could get the first occurrence to repeat the replacement

    Well that is a start.  After replacing one or two instances did you click "Find next" to skip an instance and observe that the search starts over in files that have already been searched?  This behavior has been around for years and years - I have on many occasions (like yesterday) resorted to text search from windows file manager and opened files individually and replaced text.  It really bugged me yesterday that this core functionality has been broken for so long.

    I made the screen capture with a free utility from Jing.  I am a bit challenged in the graphics/video format area so I cant do any more than tell you that.

    Since I am this far down the road I'll post the issue on stack overflow and see if anyone else can duplicate it. 

    Friday, January 29, 2016 5:17 PM
  • >Well that is a start.  After replacing one or two instances did you click "Find next" to skip an instance and observe that the search starts over in files that have already been searched?

    I hadn't, but I have now and can confirm that it does go back to other
    files. It's almost as if the Replace and Find Next operations have
    their own position variables.

    I must admit that I was probably doing what I instinctively do with
    the facility, and not following exactly what you wrote because I found
    it awkward to read/follow with a single screen.

    If you've submitted a Connect bug report can you post the link here
    please.

    Dave

    Friday, January 29, 2016 5:41 PM
  • Dave I am not going to write up a bug report and here is why:

    http://stackoverflow.com/questions/58425/wpf-application-fails-on-startup-with-typeinitializationexception

    The above link is totally unrelated to this thread except as follows:

    Ironically I ran into this exact issue ten minutes ago using VS 2015. I noticed this issue was discussed on the thread above in 2011 - almost 5 years ago.  So I'm thinking the odds are pretty slim that things get fixed in VS.

       

    Friday, January 29, 2016 5:52 PM
  • >...So I'm thinking the odds are pretty slim that things get fixed in VS.

    They won't be fixed if people don't file bug reports :(

    I feel for people's pain in doing bug reports; I've submitted bug
    reports that appear to have been ignored (I've got one at the minute
    for a bug that I feel is a design issue with an aspect of the UWP
    framework), and others that have had good responses from MS and have
    been fixed.

    If you want to see some possibility of this issue that clearly annoys
    you intensely being fixed, please submit a bug report on the MS
    connect site: https://connect.microsoft.com/visualStudio/

    If the report contains a sample project and clear instructions that
    makes someone's life easy in reproducing the issue, there's a good
    chance it won't get discarded.

    Dave

    Friday, January 29, 2016 6:08 PM
  • OK thanks for your help Dave.
    Friday, January 29, 2016 6:42 PM
  • I can tell that you're frustrated.  But, please don't be discouraged against continuing to champion this bug / feature request.  The most you get out of life is what you ask for.

    The main reason fixes are deferred is because the majority of people will simply tolerate the defect if doesn't affect anyone's business significantly enough for it to be a priority.

    If you don't get what you ask for, then you have to start influencing people to get what you want.  Determining what will compel Microsoft to fix it is a challenge for all of us.

    The two main ways to influence are:

    1) Find others with the same problem as you.  Be their voice but let them amplify your signal with their votes of support.  There are voting features at connect.microsoft.com.  The "me too" aspect of up-voting is important.

    2) Describe how you are affected and what damages you've incurred.  If there's a tenable workaround then it's less of a business priority (for Microsoft) to fix it.  You have to let them know if the workaround is not practicable for you.  But you also have to be honest about what the material impact to your own business is.  If all it causes you is annoyance then, honestly, annoyance costs you nothing.  Whereas if your losses in time are costing you significant amounts of money, or you are getting incorrect edits that affect code quality, then you have to cite those examples explicitly.  It's up to you to spin it so that it's compelling.

    Your comment about it being "shameful" is just not compelling from business stance.  It's dramatic, but you're trying to influence the business executives, product managers, and engineers that control whether or not a fix will be created -- and they all have filters when it comes to drama.  Take a new tack.

    Start by reporting the bug at connect.microsoft.com, then rally support for it.

    Don't give up!  You can do it!

    Friday, January 29, 2016 6:57 PM
  • Saturday, January 30, 2016 1:38 AM
  • Hi SWheaties,

    As you already submit one feedback on the Microsoft Connect site, let's focus on the case on that channel, I think the senior members can provide more professional support.

    I will help you vote it.

    Thanks,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, January 30, 2016 4:22 AM
    Moderator