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/src/parser.hpp b/src/parser.hpp
index 3c009e6..c2cd8d6 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -24,6 +24,12 @@
~TooManyArgumentsException() override;
};
+struct Completions {
+ bool operator==(const Completions& b) const;
+ std::set<std::string> m_completions;
+ int m_contextLength;
+};
+
class Parser {
public:
Parser(const std::shared_ptr<const Schema> schema);
@@ -31,7 +37,7 @@
void changeNode(const dataPath_& name);
std::string currentNode() const;
std::set<std::string> availableNodes(const boost::optional<boost::variant<boost::variant<dataPath_, schemaPath_>, module_>>& path, const Recursion& option) const;
- std::set<std::string> completeCommand(const std::string& line, std::ostream& errorStream) const;
+ Completions completeCommand(const std::string& line, std::ostream& errorStream) const;
private:
const std::shared_ptr<const Schema> m_schema;