@@ -82,6 +82,18 @@ module private Index =
8282type IIndexedNavigableItems =
8383abstract Find: searchValue : string -> INavigateToSearchResult []
8484
85+ let private navigateToSearchResultComparer =
86+ { new IEqualityComparer< INavigateToSearchResult> with
87+ member __.Equals ( x : INavigateToSearchResult , y : INavigateToSearchResult ) =
88+ match x, ywith
89+ | null , _ | _, null -> false
90+ | _ -> x.NavigableItem.Document.Id= y.NavigableItem.Document.Id&&
91+ x.NavigableItem.SourceSpan= y.NavigableItem.SourceSpan
92+
93+ member __.GetHashCode ( x : INavigateToSearchResult ) =
94+ if isNull xthen 0
95+ else 23 * ( 17 * 23 + x.NavigableItem.Document.Id.GetHashCode()) + x.NavigableItem.SourceSpan.GetHashCode() }
96+
8597let build ( items : seq < NavigableItem >) =
8698let entries = ResizeArray()
8799
@@ -97,7 +109,7 @@ module private Index =
97109 entries.Sort( indexEntryComparer)
98110{ new IIndexedNavigableItemswith
99111member __.Find ( searchValue ) =
100- let result = ResizeArray ( )
112+ let result = HashSet ( navigateToSearchResultComparer )
101113if entries.Count> 0 then
102114let entryToFind = IndexEntry( searchValue, 0 , Unchecked.defaultof<_>, Unchecked.defaultof<_>)
103115
@@ -113,7 +125,7 @@ module private Index =
113125else NavigateToMatchKind.Prefix
114126else NavigateToMatchKind.Substring
115127let item = entry.Item
116- result.Add( NavigateToSearchResult( item, matchKind) :> INavigateToSearchResult )
128+ result.Add( NavigateToSearchResult( item, matchKind) :> INavigateToSearchResult ) |> ignore
117129
118130// in case if there are multiple matching items binary search might return not the first one.
119131// in this case we'll walk backwards searching for the applicable answers
@@ -127,7 +139,7 @@ module private Index =
127139while pos< entries.Count&& entries.[ pos]. StartsWith searchValuedo
128140 handle pos
129141 pos<- pos+ 1
130- result.ToArray () }
142+ Seq.toArray result }
131143
132144module private Utils =
133145let navigateToItemKindToRoslynKind = function
@@ -207,6 +219,7 @@ type internal FSharpNavigateToSearchService
207219| _ ->
208220let! items = getNavigableItems( document, options, cancellationToken)
209221let indexedItems = Index.build items
222+ itemsByDocumentId.Remove( document.Id) |> ignore
210223 itemsByDocumentId.Add( document.Id, ( textVersionHash, indexedItems))
211224return indexedItems
212225}