refactor: optimize fuzzy matching with lazy initialization (#2523)

This commit is contained in:
Valentin Maerten
2025-12-07 21:43:26 +01:00
committed by GitHub
parent b1814277c2
commit a40ddd4949
12 changed files with 64 additions and 10 deletions

View File

@@ -40,6 +40,7 @@ type (
Watch bool
Verbose bool
Silent bool
DisableFuzzy bool
AssumeYes bool
AssumeTerm bool // Used for testing
Dry bool
@@ -65,7 +66,8 @@ type (
UserWorkingDir string
EnableVersionCheck bool
fuzzyModel *fuzzy.Model
fuzzyModel *fuzzy.Model
fuzzyModelOnce sync.Once
concurrencySemaphore chan struct{}
taskCallCount map[string]*int32
@@ -312,6 +314,19 @@ func (o *silentOption) ApplyToExecutor(e *Executor) {
e.Silent = o.silent
}
// WithDisableFuzzy tells the [Executor] to disable fuzzy matching for task names.
func WithDisableFuzzy(disableFuzzy bool) ExecutorOption {
return &disableFuzzyOption{disableFuzzy}
}
type disableFuzzyOption struct {
disableFuzzy bool
}
func (o *disableFuzzyOption) ApplyToExecutor(e *Executor) {
e.DisableFuzzy = o.disableFuzzy
}
// WithAssumeYes tells the [Executor] to assume "yes" for all prompts.
func WithAssumeYes(assumeYes bool) ExecutorOption {
return &assumeYesOption{assumeYes}