There should be no trailing space when completing directories for a file match based on patterns
This commit is contained in:
parent
3c0667afd6
commit
4fc91dcc03
@ -132,7 +132,7 @@ func (self *Completions) AddMatchGroup(title string) *MatchGroup {
|
|||||||
return &ans
|
return &ans
|
||||||
}
|
}
|
||||||
|
|
||||||
type CompletionFunc func(completions *Completions, word string, arg_num int)
|
type CompletionFunc = func(completions *Completions, word string, arg_num int)
|
||||||
|
|
||||||
func NamesCompleter(title string, names ...string) CompletionFunc {
|
func NamesCompleter(title string, names ...string) CompletionFunc {
|
||||||
return func(completions *Completions, word string, arg_num int) {
|
return func(completions *Completions, word string, arg_num int) {
|
||||||
|
|||||||
@ -244,9 +244,25 @@ func make_completer(title string, relative_to relative_to, patterns []string, f
|
|||||||
return func(completions *Completions, word string, arg_num int) {
|
return func(completions *Completions, word string, arg_num int) {
|
||||||
q := f(word, cwd, lpats)
|
q := f(word, cwd, lpats)
|
||||||
if len(q) > 0 {
|
if len(q) > 0 {
|
||||||
|
dirs, files := make([]string, 0, len(q)), make([]string, 0, len(q))
|
||||||
|
for _, x := range q {
|
||||||
|
if strings.HasSuffix(x, "/") {
|
||||||
|
dirs = append(dirs, x)
|
||||||
|
} else {
|
||||||
|
files = append(files, x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(dirs) > 0 {
|
||||||
|
mg := completions.AddMatchGroup("Directories")
|
||||||
|
mg.IsFiles = true
|
||||||
|
mg.NoTrailingSpace = true
|
||||||
|
for _, c := range dirs {
|
||||||
|
mg.AddMatch(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
mg := completions.AddMatchGroup(title)
|
mg := completions.AddMatchGroup(title)
|
||||||
mg.IsFiles = true
|
mg.IsFiles = true
|
||||||
for _, c := range q {
|
for _, c := range files {
|
||||||
mg.AddMatch(c)
|
mg.AddMatch(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user