diff --git a/cmd/micro/messenger.go b/cmd/micro/messenger.go index 33021f97..646d8123 100644 --- a/cmd/micro/messenger.go +++ b/cmd/micro/messenger.go @@ -322,7 +322,7 @@ func (m *Messenger) Prompt(prompt, placeholder, historyType string, completionTy chosen = chosen + CommonSubstring(suggestions...) } - if chosen != "" { + if len(suggestions) != 0 { m.response = shellwords.Join(append(args[:len(args)-1], chosen)...) m.cursorx = Count(m.response) } diff --git a/cmd/micro/shellwords/shellwords.go b/cmd/micro/shellwords/shellwords.go index b99c27d0..99a506c6 100644 --- a/cmd/micro/shellwords/shellwords.go +++ b/cmd/micro/shellwords/shellwords.go @@ -168,19 +168,10 @@ func Join(args ...string) string { for _, b := range w { switch b { - case 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', - 'v', 'w', 'x', 'y', 'z', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', - 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '_', '-', '.', ',', ':', '/', '@': + case ' ', '\t', '\r', '\n': + buf.WriteByte('\\') buf.WriteString(string(b)) default: - buf.WriteByte('\\') buf.WriteString(string(b)) } }