Navigation Menu

Skip to content

Commit

Permalink
Quote file path separator in the filename completer.
Browse files Browse the repository at this point in the history
This is needed on Windows.
  • Loading branch information
xiaq committed Sep 23, 2018
1 parent bfb4922 commit 9009bd7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions edit/completion/complete_arg.go
Expand Up @@ -70,6 +70,8 @@ func (ctx *argComplContext) generate(env *complEnv, ch chan<- rawCandidate) erro
return completeArg(ctx.words, env.evaler, env.argCompleter, ch)
}

var quotedPathSeparator = parse.Quote(string(filepath.Separator))

// TODO: getStyle does redundant stats.
func complFilenameInner(head string, executableOnly bool, rawCands chan<- rawCandidate) error {
dir, fileprefix := filepath.Split(head)
Expand Down Expand Up @@ -103,12 +105,12 @@ func complFilenameInner(head string, executableOnly bool, rawCands chan<- rawCan

suffix := " "
if info.IsDir() {
suffix = string(filepath.Separator)
suffix = quotedPathSeparator
} else if info.Mode()&os.ModeSymlink != 0 {
stat, err := os.Stat(full)
if err == nil && stat.IsDir() {
// Symlink to directory.
suffix = string(filepath.Separator)
suffix = quotedPathSeparator
}
}

Expand Down

0 comments on commit 9009bd7

Please sign in to comment.