chore(pkg): replace fuzzyvn with fuzzy
This commit is contained in:
@@ -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)
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ The `history` module provides the Ctrl+R fuzzy search functionality by reading t
|
||||
|
||||
- **Zsh Extended Support**: Specifically parses the `: <timestamp>;<command>` 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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=
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user