diff --git a/operation.go b/operation.go index 5842480..02cc2e3 100644 --- a/operation.go +++ b/operation.go @@ -405,6 +405,10 @@ func (op *Operation) SetConfig(cfg *Config) (*Config, error) { // so if we use it next time, we need to reopen it by `InitHistory()` op.history.Init() + if op.cfg.AutoComplete != nil { + op.opCompleter = newOpCompleter(op.buf.w, op) + } + op.opSearch = cfg.opSearch return old, nil } diff --git a/std.go b/std.go index 200420b..326e64b 100644 --- a/std.go +++ b/std.go @@ -33,6 +33,13 @@ func SetHistoryPath(fp string) { ins.SetConfig(cfg) } +func SetAutoComplete(completer AutoCompleter) { + ins := getInstance() + cfg := ins.Config.Clone() + cfg.AutoComplete = completer + ins.SetConfig(cfg) +} + func AddHistory(content string) error { ins := getInstance() return ins.SaveHistory(content)