Don't append empty comp.append

In some cases, comp.append could be an empty string. This would happen
if a parser was something like `(token(foo) <~ ;).+ <~ fo.?` because there were
no completions for the `fo` available anchor. The effect of this was
that tab would never complete foo;f to foo;foo, even though that was the
only possible completion. It would, _display_, foo as a possible
completion though.

This came up because the multi parser has a similar parser to that
described above and it broke tab completion to the right of a semi
colon.
This commit is contained in:
Ethan Atkins 2019-06-24 22:43:57 -07:00
parent 60b1ac7ac4
commit 4e2c1858f2
1 changed files with 2 additions and 1 deletions

View File

@ -83,7 +83,8 @@ object JLineCompletion {
val (insert, display) =
((Set.empty[String], Set.empty[String]) /: cs) {
case (t @ (insert, display), comp) =>
if (comp.isEmpty) t else (insert + comp.append, appendNonEmpty(display, comp.display))
if (comp.isEmpty) t
else (appendNonEmpty(insert, comp.append), appendNonEmpty(display, comp.display))
}
(insert.toSeq, display.toSeq.sorted)
}