Merge "Build with C++20"
diff --git a/src/path_parser.hpp b/src/path_parser.hpp
index 04a2dba..eb34033 100644
--- a/src/path_parser.hpp
+++ b/src/path_parser.hpp
@@ -291,13 +291,18 @@
if constexpr (PARSER_MODE == PathParserMode::DataPathListEnd || PARSER_MODE == PathParserMode::AnyPath) {
if (!res || !pathEnd.parse(begin, end, ctx, rctx, x3::unused)) {
dataNode_ attrNodeList;
- res = incompleteDataNode<COMPLETION_MODE>{m_filterFunction}.parse(begin, end, ctx, rctx, attrNodeList);
- if (res) {
+ auto hasListEnd = incompleteDataNode<COMPLETION_MODE>{m_filterFunction}.parse(begin, end, ctx, rctx, attrNodeList);
+ if (hasListEnd) {
attrData.m_nodes.emplace_back(attrNodeList);
- // If the trailing slash matches, no more nodes are parsed.
- // That means no more completion. So, I generate them
- // manually.
- res = (-(trailingSlash >> x3::omit[pathCompletions<COMPLETION_MODE>{m_filterFunction}])).parse(begin, end, ctx, rctx, attrData.m_trailingSlash);
+ // If the trailing slash matches, no more nodes are parsed. That means no more completion. So, I
+ // generate them manually, but only if we're in AnyPath mode, so, for example, inside an `ls`
+ // command. If we're in DataPathListEnd it doesn't make sense to parse put any more nodes after the
+ // final list.
+ if constexpr (PARSER_MODE == PathParserMode::AnyPath) {
+ res = (-(trailingSlash >> x3::omit[pathCompletions<COMPLETION_MODE>{m_filterFunction}])).parse(begin, end, ctx, rctx, attrData.m_trailingSlash);
+ } else {
+ res = (-trailingSlash).parse(begin, end, ctx, rctx, attrData.m_trailingSlash);
+ }
}
}
}
@@ -460,7 +465,6 @@
auto const getPath_def =
PathParser<PathParserMode::DataPathListEnd, CompletionMode::Data>{noRpcOrAction} |
- PathParser<PathParserMode::DataPath, CompletionMode::Data>{noRpcOrAction} |
(module >> "*");
auto const cdPath_def =
diff --git a/tests/path_completion.cpp b/tests/path_completion.cpp
index 4b6b25b..ffd3e93 100644
--- a/tests/path_completion.cpp
+++ b/tests/path_completion.cpp
@@ -187,6 +187,24 @@
}
}
+ SECTION("get completion")
+ {
+ SECTION("get /example:ano/l")
+ {
+ input = "get /example:ano/l";
+ expectedCompletions = {"listInCont"};
+ expectedContextLength = 1;
+ }
+
+ SECTION("get /example:list/")
+ {
+ input = "get /example:list/";
+ expectedCompletions = {};
+ // The expectedContextLength is 13, because the completion isn't actually generated after the slash.
+ expectedContextLength = 13;
+ }
+ }
+
SECTION("list keys completion")
{
SECTION("cd example:lis")