1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

refactor: lazy load fuzzy model & ability to disable it

This commit is contained in:
Valentin Maerten
2025-11-23 21:12:25 +01:00
parent f29d718b03
commit 876bb33de2
11 changed files with 81 additions and 26 deletions

10
task.go
View File

@@ -452,8 +452,14 @@ func (e *Executor) GetTask(call *Call) (*ast.Task, error) {
// If we found no tasks
if len(aliasedTasks) == 0 {
didYouMean := ""
if e.fuzzyModel != nil {
didYouMean = e.fuzzyModel.SpellCheck(call.Task)
if !e.DisableFuzzy {
// Lazy initialization of fuzzy model
if e.fuzzyModel == nil {
e.setupFuzzyModel()
}
if e.fuzzyModel != nil {
didYouMean = e.fuzzyModel.SpellCheck(call.Task)
}
}
return nil, &errors.TaskNotFoundError{
TaskName: call.Task,