fix(spec): remove sync.Once so we can always up-to-date with shell config

This commit is contained in:
verse91
2026-04-11 21:36:08 +07:00
parent 02fdd99e40
commit 8b25bdac0f
+4 -4
View File
@@ -4,7 +4,6 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"sync"
) )
type GeneratorFunc func(tokens []string, prefix string, partial string) []Suggestion type GeneratorFunc func(tokens []string, prefix string, partial string) []Suggestion
@@ -46,7 +45,6 @@ var (
registry = map[string]*Spec{} registry = map[string]*Spec{}
pathCmds = make(map[string]bool) pathCmds = make(map[string]bool)
shellAliases = make(map[string]string) // alias name -> target command shellAliases = make(map[string]string) // alias name -> target command
pathOnce sync.Once
) )
// scanShellAliases parses shell config files for aliases // scanShellAliases parses shell config files for aliases
@@ -152,7 +150,10 @@ func Register(s *Spec) {
// //
// priority: file/dir -> subcommands -> options // priority: file/dir -> subcommands -> options
func Lookup(input string) []Suggestion { func Lookup(input string) []Suggestion {
pathOnce.Do(scanExternalCommands) shellAliases = make(map[string]string)
pathCmds = make(map[string]bool)
scanExternalCommands()
tokens := tokenize(input) tokens := tokenize(input)
// Token Injection: resolve shell alias (e.g. gca -> git commit -a) // Token Injection: resolve shell alias (e.g. gca -> git commit -a)
@@ -272,7 +273,6 @@ func Lookup(input string) []Suggestion {
} }
func topLevelSuggestions(query string) []Suggestion { func topLevelSuggestions(query string) []Suggestion {
pathOnce.Do(scanExternalCommands)
results, seen := []Suggestion{}, make(map[string]bool) results, seen := []Suggestion{}, make(map[string]bool)
// 1. Manual specs (High Priority) // 1. Manual specs (High Priority)