locked
Clearing a File in Files filter RRS feed

  • Question

  • I have an VSPackage that performs a complex Find in Files search.  I do this by setting DTE.Find.FilesOfType to be a list of files I need to search.  The downside to this is it places a huge string in the history.  I'd like to stop it from adding the custom search to the history, or remove it.  I've looked at just removing it from the registry but VS doesn't seem to store the history in to the registry until close so that doesn't work.  Is there a way to get to this information?

    This is in Visual Studio 2010 SP1.

    • Edited by Joe NC Friday, January 27, 2012 3:10 PM
    Friday, January 27, 2012 3:10 PM

Answers

  • According to MSDN (emphasis mine):

    The Execute method performs a Find operation based on the settings of the Find object. You can also pass arguments to the FindReplace method to perform a search without affecting the global find state. It is important for automation clients to be able to perform a search without affecting the global find state or interfering with the end user's model of the environment's state.

    Have you tried that route?

    Ryan

    • Marked as answer by Joe NC Tuesday, January 31, 2012 11:11 PM
    Tuesday, January 31, 2012 7:38 PM

All replies

  • Hi Joe,

    You can see the find history in the Computer->HKEY_CURRENT_USER->Software->Microsoft->VisualStudio->10.0->Find.

    When we close the VS, then we will find the VS add new find history to the register. If you want to clear these find history, you can delete the Find key in the register. Or try to use the RegDeleteKey function to delete it.

    Reference:

    Deleting a Key with Subkeys:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms724235(v=vs.85).aspx

    RegDeleteKey function

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms724845(v=vs.85).aspx

     

    Best regards,

    Lucy

     


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 31, 2012 5:24 AM
  • Thanks Lucy, but I had that part already :). My problem was that the new history isn't exported to the registry until VS closes.  I'm looking for a way to clean up the history while running or how to perform a find in files search without cluttering the history to begin with.  But it's looking more and more like I'm going to need to reinvent the wheel here.

    Is there any way to provide a list of files/items to search instead of having to cram a large fileset in to DTE.Find.FilesOfType?

    Tuesday, January 31, 2012 6:52 PM
  • According to MSDN (emphasis mine):

    The Execute method performs a Find operation based on the settings of the Find object. You can also pass arguments to the FindReplace method to perform a search without affecting the global find state. It is important for automation clients to be able to perform a search without affecting the global find state or interfering with the end user's model of the environment's state.

    Have you tried that route?

    Ryan

    • Marked as answer by Joe NC Tuesday, January 31, 2012 11:11 PM
    Tuesday, January 31, 2012 7:38 PM
  • I have tried it.  Maybe I'm doing something wrong but nothing I send pass to DTE.Find.FindReplace seems to work.  Here is a code snippet...

    EnvDTE.DTE DTE = VisualUCPackage.DTE;
    
    DTE.Find.Action = EnvDTE.vsFindAction.vsFindActionFindAll;
    DTE.Find.Backwards = false;
    DTE.Find.FilesOfType = FileList;
    DTE.Find.FindWhat = FindText;
    DTE.Find.KeepModifiedDocumentsOpen = true;
    DTE.Find.MatchCase = false;
    DTE.Find.MatchInHiddenText = false;
    DTE.Find.MatchWholeWord = false;
    DTE.Find.ResultsLocation = EnvDTE.vsFindResultsLocation.vsFindResults1;
    DTE.Find.Target = EnvDTE.vsFindTarget.vsFindTargetSolution;
    DTE.Find.Execute();
    

    That works, but since FileList can be a rather large list of file that goes stored in the history it's not optimal.  This:

    int FindOptions = (int) EnvDTE.vsFindOptions.vsFindOptionsSearchSubfolders;
    DTE.Find.FindReplace(EnvDTE.vsFindAction.vsFindActionFindAll, FindText, FindOptions,"",
    EnvDTE.vsFindTarget.vsFindTargetFiles, FileList, "*.*",
    EnvDTE.vsFindResultsLocation.vsFindResults1);

    Does not work.  I was also unsuccessful passing FilesOfType as "" or as the filelist. 


    Tuesday, January 31, 2012 9:37 PM
  • Can you clarify what you mean by 'doesn't work'?  Returns some kind of failure?  Doesn't show any results?  Something else?

    Ryan

    Tuesday, January 31, 2012 10:43 PM
  • Sorry, doesn't return any results. I got it figured out.  I needed to use vsFindTargetSolution instead of vsFindTargetFiles. 

    Tuesday, January 31, 2012 11:11 PM
  • There does seem to be a bug here.  When I use DTE.Find.FindReplace() the resulting output says:

    Find all "xxxx" ....

    But the  "xxxx" isn't my text rather it's the text from the last VS find that was executed.  The search gives the right results however.

    Sunday, February 5, 2012 4:58 AM
  • I can file a bug, likely an unintended consequence of 'doesn't change global state', it sounds like the code that prints out the line is using said global state, possibly because the search string you give doesn't propagate directly to that code.

    Ryan

    Sunday, February 5, 2012 5:35 PM