Implement tab completion - continued
I hit submit instead of reply on v.io/c/23651,
so I'm fixing the comments here.
Change-Id: I3de2a780ed2a82fc75c3f0914c57afff861778da
diff --git a/cmd/sb/internal/reader/reader.go b/cmd/sb/internal/reader/reader.go
index 9c481b2..0412740 100644
--- a/cmd/sb/internal/reader/reader.go
+++ b/cmd/sb/internal/reader/reader.go
@@ -145,7 +145,7 @@
}
func complete(line string) []string {
- // get command list to tab-complete on
+ // Get command list to tab-complete on.
tokens := strings.Split(line, " ")
cmds := commands.Commands
for _, token := range tokens[:len(tokens)-1] {
@@ -157,13 +157,9 @@
}
}
- lineMinusLastToken := strings.Join(tokens[:len(tokens)-1], " ")
- if len(lineMinusLastToken) > 0 {
- lineMinusLastToken += " "
- }
-
- // tab complete on command list
+ // Tab complete on command list.
lastToken := tokens[len(tokens)-1]
+ lineMinusLastToken := line[:len(line)-len(lastToken)]
var ret []string
for _, cmd := range cmds {
name := cmd.Name