Change how word splitting works when completing
Previously, I relied on replxx to correctly split words based on
word-splitting characters. However, as completion gets more complex and
completions possibly insert word-splitting characters, it starts to do
weird stuff like deleting some of your input. Fortunately, replxx allows
you to set the context length for completion - that is, how many
character it should consider as part of the word you're completing.
Change-Id: I035ac5059c8ab125efedb90cbeb2910f20da04a7
diff --git a/tests/enum_completion.cpp b/tests/enum_completion.cpp
index d7dfd58..29f23a7 100644
--- a/tests/enum_completion.cpp
+++ b/tests/enum_completion.cpp
@@ -9,6 +9,7 @@
#include "trompeloeil_doctest.h"
#include "parser.hpp"
+#include "pretty_printers.hpp"
#include "static_schema.hpp"
TEST_CASE("enum completion")
@@ -25,38 +26,44 @@
std::string input;
std::ostringstream errorStream;
- std::set<std::string> expected;
+ std::set<std::string> expectedCompletions;
+ int expectedContextLength;
SECTION("set mod:leafEnum ")
{
input = "set mod:leafEnum ";
- expected = {"lala", "lol", "data", "coze"};
+ expectedCompletions = {"lala", "lol", "data", "coze"};
+ expectedContextLength = 0;
}
SECTION("set mod:leafEnum c")
{
input = "set mod:leafEnum c";
- expected = {"coze"};
+ expectedCompletions = {"coze"};
+ expectedContextLength = 1;
}
SECTION("set mod:leafEnum l")
{
input = "set mod:leafEnum l";
- expected = {"lala", "lol"};
+ expectedCompletions = {"lala", "lol"};
+ expectedContextLength = 1;
}
SECTION("set mod:contA/leafInCont ")
{
input = "set mod:contA/leafInCont ";
- expected = {"abc", "def"};
+ expectedCompletions = {"abc", "def"};
+ expectedContextLength = 0;
}
SECTION("set mod:list[number=42]/leafInList ")
{
input = "set mod:list[number=42]/leafInList ";
- expected = {"ano", "anoda", "ne", "katoda"};
+ expectedCompletions = {"ano", "anoda", "ne", "katoda"};
+ expectedContextLength = 0;
}
- REQUIRE(parser.completeCommand(input, errorStream) == expected);
+ REQUIRE(parser.completeCommand(input, errorStream) == (Completions{expectedCompletions, expectedContextLength}));
}