From e15e88e53d5f2d880f3d1b623861d1a0e7be7910 Mon Sep 17 00:00:00 2001 From: verse91 Date: Sun, 10 May 2026 00:18:14 +0700 Subject: [PATCH] chore(pkg): replace fuzzyvn with fuzzy --- commands/fs/zoxide.go | 6 +++--- docs/history.md | 4 ++-- go.mod | 5 ++--- go.sum | 2 -- integration/history.go | 10 +++++----- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/commands/fs/zoxide.go b/commands/fs/zoxide.go index 08785c6..2e86b83 100644 --- a/commands/fs/zoxide.go +++ b/commands/fs/zoxide.go @@ -11,7 +11,7 @@ import ( "os/exec" "strings" - "github.com/versenilvis/fuzzyvn" + "github.com/versenilvis/fuzzy" "github.com/versenilvis/iris/commands/core" ) @@ -64,8 +64,8 @@ func ZoxideGenerator() core.GeneratorFunc { }) } } else if !strings.Contains(fullQuery, "/") { - searcher := fuzzyvn.NewPlainSearcher(dirs) - matches := searcher.SearchWithScores(fullQuery, &fuzzyvn.SearchOptions{Limit: 10}) + searcher := fuzzy.NewPlainSearcher(dirs) + matches := searcher.SearchWithScores(fullQuery, &fuzzy.SearchOptions{Limit: 10}) for _, m := range matches { path := m.Str display := strings.Replace(path, home, "~", 1) diff --git a/docs/history.md b/docs/history.md index 84e66e2..95263dc 100644 --- a/docs/history.md +++ b/docs/history.md @@ -6,7 +6,7 @@ The `history` module provides the Ctrl+R fuzzy search functionality by reading t - **Zsh Extended Support**: Specifically parses the `: ;` format common in Zsh. - **Lazy Loading**: Doesn't read the disk until the user actually requests history. This keeps startup time instantaneous. -- **Fuzzy Search**: Integrated with the `fuzzyvn` search engine. +- **Fuzzy Search**: Integrated with the `fuzzy` search engine. - **Deduplication**: Automatically hides duplicate entries, showing only the most unique command variants. ## Data Flow @@ -18,7 +18,7 @@ The `history` module provides the Ctrl+R fuzzy search functionality by reading t - Reads `~/.zsh_history`. - Strips metadata using `;` delimiter. - Populates a slice of commands. -5. Search matches are sorted by the `fuzzyvn` engine. +5. Search matches are sorted by the `fuzzy` engine. 6. Suggestions are returned to the `overlay` for rendering. ## Configuration diff --git a/go.mod b/go.mod index 32d3326..0fe24ae 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/charmbracelet/lipgloss v1.1.0 github.com/creack/pty v1.1.24 github.com/spf13/cobra v1.10.2 - github.com/versenilvis/fuzzyvn v0.3.0 golang.org/x/sys v0.42.0 golang.org/x/term v0.41.0 ) @@ -27,10 +26,10 @@ require ( github.com/muesli/termenv v0.16.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/spf13/pflag v1.0.10 // indirect + github.com/versenilvis/fuzzy v0.1.0-rc // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect - golang.org/x/text v0.32.0 // indirect ) // this is my personal project, I want to point to my local folder to debug and develop // the github version is the stable one -replace github.com/versenilvis/fuzzyvn => ../fuzzyvn +replace github.com/versenilvis/fuzzy => ../fuzzy diff --git a/go.sum b/go.sum index c6f33e4..baf79b0 100644 --- a/go.sum +++ b/go.sum @@ -47,6 +47,4 @@ golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU= golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/integration/history.go b/integration/history.go index 7acf155..d3d37c2 100644 --- a/integration/history.go +++ b/integration/history.go @@ -8,14 +8,14 @@ import ( "strings" "sync" - "github.com/versenilvis/fuzzyvn" + "github.com/versenilvis/fuzzy" "github.com/versenilvis/iris/integration/shell" ) var ( historyCache []string idMapCache map[string]int - searcherCache *fuzzyvn.Searcher + searcherCache *fuzzy.Searcher mu sync.Mutex lastModTime int64 ) @@ -120,7 +120,7 @@ func SearchHistory(query string) ([]HistResult, error) { } } - searcherCache = fuzzyvn.NewPlainSearcher(historyCache) + searcherCache = fuzzy.NewPlainSearcher(historyCache) } if query == "" { @@ -140,7 +140,7 @@ func SearchHistory(query string) ([]HistResult, error) { return results, nil } - matches := searcherCache.SearchWithScores(query, &fuzzyvn.SearchOptions{Limit: 100}) + matches := searcherCache.SearchWithScores(query, &fuzzy.SearchOptions{Limit: 100}) var results []HistResult for _, m := range matches { @@ -178,7 +178,7 @@ func SearchHistory(query string) ([]HistResult, error) { return tI < tJ // lower tier is better } - // If both are fuzzy matches (Tier 4), prioritize fuzzyvn score first! + // If both are fuzzy matches (Tier 4), prioritize fuzzy score first! if tI == 4 && results[i].FuzzyScore != results[j].FuzzyScore { return results[i].FuzzyScore > results[j].FuzzyScore }