Let edit.completion embed edit.compl.

This commit is contained in:
Qi Xiao 2017-02-13 00:54:32 -05:00
parent 18c06f6a5b
commit 79350d7b9c

View File

@ -14,9 +14,8 @@ import (
// Interface.
type completion struct {
compl
completer string
begin, end int
candidates []*candidate
filtering bool
filter string
@ -156,13 +155,13 @@ func startCompletionInner(ed *Editor, acceptPrefix bool) {
return
}
c := &completion{begin: -1}
c := &completion{}
shownError := false
for _, item := range completers {
compl, err := item.completer(node, ed.evaler)
if compl != nil {
c.completer = item.name
c.begin, c.end, c.candidates = compl.begin, compl.end, compl.candidates
c.compl = *compl
c.filtered = c.candidates
break
} else if err != nil && err != errCompletionUnapplicable {
@ -172,7 +171,7 @@ func startCompletionInner(ed *Editor, acceptPrefix bool) {
}
}
if c.begin < 0 {
if c.completer == "" {
if !shownError {
ed.addTip("unsupported completion :(")
}