Improve command bar completion

This commit is contained in:
Zachary Yedidia
2018-01-03 21:35:03 -05:00
parent 8b60e4f3b1
commit a814677b51
2 changed files with 3 additions and 12 deletions

View File

@@ -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)
}

View File

@@ -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))
}
}