This commit is contained in:
Pristáš Michal 2016-04-07 09:55:33 +02:00
parent f2a9cba613
commit 03359d475e
2 changed files with 14 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package readline
import (
"bytes"
"strings"
"github.com/chzyer/readline/runes"
)
type PrefixCompleterInterface interface {
@ -73,7 +75,7 @@ func (p *PrefixCompleter) Do(line []rune, pos int) (newLine [][]rune, offset int
}
func Do(p PrefixCompleterInterface, line []rune, pos int) (newLine [][]rune, offset int) {
line = line[:pos]
line = runes.TrimSpaceLeft(line[:pos])
goNext := false
var lineCompleter PrefixCompleterInterface
for _, child := range p.GetChildren() {

View File

@ -154,3 +154,14 @@ aggregate:
}
return
}
func TrimSpaceLeft(in []rune) []rune {
firstIndex := 0
for i, r := range in {
if unicode.IsSpace(r) == false {
firstIndex = i
break
}
}
return in[firstIndex:]
}