From 4e2c1858f2a5333977a438514582241e75e21da0 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Mon, 24 Jun 2019 22:43:57 -0700 Subject: [PATCH] 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. --- .../scala/sbt/internal/util/complete/JLineCompletion.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala b/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala index eb955ffd2..fc9f2f49a 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala @@ -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) }