Find Symbol Result Window got double results when I search object use IVsSimpleLibrary2 RRS feed

  • Question

  • I implement IVsSimpleLibrary2 and IVsSimpleObjectList2 for "find all reference".. and I could query result from list.. While, whenever code run into method doSearch()..GetList2 of IVsSimpleLibrary seems to be called twice and return double information of results..How did it happened?

    Code's below:

     IVsObjectSearch search = GetService(typeof (SVsObjectSearch)) as IVsObjectSearch;
     IVsFindSymbol find = search as IVsFindSymbol;
      criteria = new VSOBSEARCHCRITERIA2[1];
     criteria[0].eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD;
       criteria[0].szName = strText;
      Guid g = new Guid("0925166e-a743-49e2-9224-bbe206545104");
      ObjectLib = new SearchLibrary(g, strText);
      uint SearchCookie;
      IVsObjectManager2 objManager = GetService(typeof(SVsObjectManager)) as IVsObjectManager2;
       objManager.RegisterSimpleLibrary(ObjectLib, out SearchCookie);
    int returnValue = find.DoSearch(ref g, criteria);

    • Edited by treeshadow Tuesday, May 7, 2013 6:34 AM
    Monday, May 6, 2013 10:10 AM

All replies

  • If we debug your codes and add a breakpoint, can we find why it be hit twice?


    Wednesday, May 8, 2013 2:55 AM
  • I had this too. It turns out that GetList2 is called several times with different values for the first argument ("ListType"), and it merges copies of all the lists from each call together, resulting in duplicates.

    In my case, it was being called twice (actually several more times if you count the ones where pobSrch was null, but I already had an if filtering those out), once with ListType set to 2, and another with it set to 8, corresponding to LLT_NAMESPACES and LLT_MEMBERS, respectively. Why these two and not others? I have no idea. My own code doesn't mention those constants anywhere else!

    Long story short, you just need to add an if to check for what ListType is being passed in, and return VSConstants.E_NOTIMPL for all except one.

    Monday, March 17, 2014 7:54 PM