mirror of https://github.com/Hilbis/Hilbish
fix: dont trim trailing space for completion field
parent
65435572d4
commit
7ab81a61df
11
rl.go
11
rl.go
|
@ -25,7 +25,7 @@ func NewLineReader(prompt string) *LineReader {
|
|||
var completions []string
|
||||
// trim whitespace from ctx
|
||||
ctx = strings.TrimLeft(ctx, " ")
|
||||
fields, ctx := splitInput(ctx)
|
||||
fields := strings.Split(ctx, " ")
|
||||
if len(fields) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
@ -67,10 +67,19 @@ func NewLineReader(prompt string) *LineReader {
|
|||
// ignore that so we have to check and just add the prefix instead
|
||||
if prefix != "./" {
|
||||
completions[0] = filepath.Join(filepath.Dir(query), completions[0])
|
||||
} else {
|
||||
dirNest := strings.Count(query, "/")
|
||||
if dirNest > 1 {
|
||||
completions[0] = prefix + filepath.Join(filepath.Dir(query), completions[0])
|
||||
} else {
|
||||
completions[0] = prefix + completions[0]
|
||||
}
|
||||
}
|
||||
|
||||
if info, err := os.Stat(strings.Replace(completions[0], "~", homedir, 1)); err == nil && info.IsDir() {
|
||||
completions[0] += "/"
|
||||
}
|
||||
}
|
||||
return completions
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue