Bump github.com/sahilm/fuzzy from 0.1.2 to 0.1.3 (#5706)

Bumps [github.com/sahilm/fuzzy](https://github.com/sahilm/fuzzy) from
0.1.2 to 0.1.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/sahilm/fuzzy/releases">github.com/sahilm/fuzzy's
releases</a>.</em></p>
<blockquote>
<h2>v0.1.3</h2>
<h2>What's Changed</h2>
<ul>
<li>Functions to use Iterators as Source by <a
href="https://github.com/wbrc"><code>@​wbrc</code></a> in <a
href="https://redirect.github.com/sahilm/fuzzy/pull/29">sahilm/fuzzy#29</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/wbrc"><code>@​wbrc</code></a> made their
first contribution in <a
href="https://redirect.github.com/sahilm/fuzzy/pull/29">sahilm/fuzzy#29</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/sahilm/fuzzy/compare/v0.1.2...v0.1.3">https://github.com/sahilm/fuzzy/compare/v0.1.2...v0.1.3</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8aadc77d46"><code>8aadc77</code></a>
Functions to use Iterators as Source (<a
href="https://redirect.github.com/sahilm/fuzzy/issues/29">#29</a>)</li>
<li>See full diff in <a
href="https://github.com/sahilm/fuzzy/compare/v0.1.2...v0.1.3">compare
view</a></li>
</ul>
</details>
<br />
This commit is contained in:
Stefan Haller 2026-07-02 07:19:38 +02:00 committed by GitHub
commit 37ab23b680
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 6 deletions

2
go.mod
View file

@ -26,7 +26,7 @@ require (
github.com/mgutz/str v1.2.0
github.com/mitchellh/go-ps v1.0.0
github.com/rivo/uniseg v0.4.7
github.com/sahilm/fuzzy v0.1.2
github.com/sahilm/fuzzy v0.1.3
github.com/samber/lo v1.53.0
github.com/sanity-io/litter v1.5.8
github.com/sasha-s/go-deadlock v0.3.9

4
go.sum
View file

@ -107,8 +107,8 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/sahilm/fuzzy v0.1.2 h1:kdSkz23lx1meNjEl+SLJULeSbjTI4Dn14K/YxdGrIww=
github.com/sahilm/fuzzy v0.1.2/go.mod h1:au6//VbVSqu6DFrkL2CfjlJ5iURpNCPeE+1GwY3XsT8=
github.com/sahilm/fuzzy v0.1.3 h1:juByESSS32nVD81vr6tHmKmA/8zde7gE+x5CLxrzXPU=
github.com/sahilm/fuzzy v0.1.3/go.mod h1:au6//VbVSqu6DFrkL2CfjlJ5iURpNCPeE+1GwY3XsT8=
github.com/samber/lo v1.53.0 h1:t975lj2py4kJPQ6haz1QMgtId2gtmfktACxIXArw3HM=
github.com/samber/lo v1.53.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
github.com/sanity-io/litter v1.5.8 h1:uM/2lKrWdGbRXDrIq08Lh9XtVYoeGtcQxk9rtQ7+rYg=

View file

@ -6,6 +6,7 @@ VSCode, IntelliJ IDEA et al.
package fuzzy
import (
"iter"
"sort"
"strings"
"unicode"
@ -60,6 +61,16 @@ func (ss stringSource) String(i int) string {
func (ss stringSource) Len() int { return len(ss) }
func iterFromSource(s Source) iter.Seq[string] {
return func(yield func(string) bool) {
for i := 0; i < s.Len(); i++ {
if !yield(s.String(i)) {
return
}
}
}
}
/*
Find looks up pattern in data and returns matches
in descending order of match quality. Match quality
@ -107,15 +118,33 @@ FindFromNoSort is an alternative FindFrom implementation that does
not sort results in the end.
*/
func FindFromNoSort(pattern string, data Source) Matches {
return FindFromIterNoSort(pattern, iterFromSource(data))
}
/*
FindFromIter is an alternative implementation of FindFrom that uses an iterator
instead of Source.
*/
func FindFromIter(pattern string, it iter.Seq[string]) Matches {
matches := FindFromIterNoSort(pattern, it)
sort.Stable(matches)
return matches
}
/*
FindFromIterNoSort is an alternative implementation of FindFromIter that does
not sort results in the end.
*/
func FindFromIterNoSort(pattern string, it iter.Seq[string]) Matches {
if len(pattern) == 0 {
return nil
}
runes := []rune(pattern)
var matches Matches
var matchedIndexes []int
for i := 0; i < data.Len(); i++ {
var i int
for matchStr := range it {
var match Match
matchStr := data.String(i)
match.Str = matchStr
// Limit matching to the first NUL rune, if any. We could maybe replace it
// with whitespace, but this way doesn't allocate so much, and the presence
@ -125,6 +154,7 @@ func FindFromNoSort(pattern string, data Source) Matches {
cleanMatchStr = cleanMatchStr[:nullI]
}
match.Index = i
i++
if matchedIndexes != nil {
match.MatchedIndexes = matchedIndexes
} else {

2
vendor/modules.txt vendored
View file

@ -130,7 +130,7 @@ github.com/pmezard/go-difflib/difflib
github.com/rivo/uniseg
# github.com/rogpeppe/go-internal v1.14.1
## explicit; go 1.23
# github.com/sahilm/fuzzy v0.1.2
# github.com/sahilm/fuzzy v0.1.3
## explicit; go 1.24.5
github.com/sahilm/fuzzy
# github.com/samber/lo v1.53.0