Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0570e2

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Remove duplicates from Navigate To (dotnet#2173)
* Navigate To does not remove duplicates* simplify navigateToSearchResultComparer.GetHashCode
1 parentef7177d commita0570e2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎vsintegration/src/FSharp.Editor/Navigation/NavigateToSearchService.fs‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ module private Index =
8282
typeIIndexedNavigableItems=
8383
abstractFind: searchValue:string->INavigateToSearchResult[]
8484

85+
letprivatenavigateToSearchResultComparer=
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 xthen0
95+
else23*(17*23+ x.NavigableItem.Document.Id.GetHashCode())+ x.NavigableItem.SourceSpan.GetHashCode()}
96+
8597
letbuild(items:seq<NavigableItem>)=
8698
letentries= ResizeArray()
8799

@@ -97,7 +109,7 @@ module private Index =
97109
entries.Sort(indexEntryComparer)
98110
{new IIndexedNavigableItemswith
99111
member__.Find(searchValue)=
100-
letresult=ResizeArray()
112+
letresult=HashSet(navigateToSearchResultComparer)
101113
if entries.Count>0then
102114
letentryToFind= IndexEntry(searchValue,0, Unchecked.defaultof<_>, Unchecked.defaultof<_>)
103115

@@ -113,7 +125,7 @@ module private Index =
113125
else NavigateToMatchKind.Prefix
114126
else NavigateToMatchKind.Substring
115127
letitem= 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 =
127139
while pos< entries.Count&& entries.[pos].StartsWith searchValuedo
128140
handle pos
129141
pos<- pos+1
130-
result.ToArray()}
142+
Seq.toArray result}
131143

132144
moduleprivateUtils=
133145
letnavigateToItemKindToRoslynKind=function
@@ -207,6 +219,7 @@ type internal FSharpNavigateToSearchService
207219
|_->
208220
let!items= getNavigableItems(document, options, cancellationToken)
209221
letindexedItems= Index.build items
222+
itemsByDocumentId.Remove(document.Id)|> ignore
210223
itemsByDocumentId.Add(document.Id,(textVersionHash, indexedItems))
211224
return indexedItems
212225
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp