summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2015-12-23 20:53:11 +0100
committerAaron Seigo <aseigo@kde.org>2015-12-23 20:53:11 +0100
commit42d772acc88a2c57b5761b67918ae7f502a9a7f9 (patch)
tree16ccd4c57a84c0c78464d60361e8369e54a36d11
parenta6d04e09a8476773c08eca37acaea95e4f83e5f2 (diff)
downloadsink-42d772acc88a2c57b5761b67918ae7f502a9a7f9.tar.gz
sink-42d772acc88a2c57b5761b67918ae7f502a9a7f9.zip
allow commands to do their own completions
-rw-r--r--akonadi2_cli/repl/replStates.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/akonadi2_cli/repl/replStates.cpp b/akonadi2_cli/repl/replStates.cpp
index ceb95ed..62888d0 100644
--- a/akonadi2_cli/repl/replStates.cpp
+++ b/akonadi2_cli/repl/replStates.cpp
@@ -149,9 +149,19 @@ static char **akonadi2_cli_tab_completion(const char *text, int start, int end)
149 149
150static char *akonadi2_cli_next_tab_complete_match(const char *text, int state) 150static char *akonadi2_cli_next_tab_complete_match(const char *text, int state)
151{ 151{
152 Syntax::List nearest = SyntaxTree::self()->nearestSyntax(tab_completion_full_state, QString(text)); 152 const QString fragment(text);
153 153 Syntax::List nearest = SyntaxTree::self()->nearestSyntax(tab_completion_full_state, fragment);
154 if (nearest.size() > state) { 154 //for (auto syntax: nearest) { qDebug() << "Nearest: " << syntax.keyword; }
155
156 if (nearest.isEmpty()) {
157 SyntaxTree::Command command = SyntaxTree::self()->match(tab_completion_full_state);
158 if (command.first && command.first->completer) {
159 QStringList commandCompletions = command.first->completer(tab_completion_full_state, fragment);
160 if (commandCompletions.size() > state) {
161 return qstrdup(commandCompletions[state].toUtf8());
162 }
163 }
164 } else if (nearest.size() > state) {
155 return qstrdup(nearest[state].keyword.toUtf8()); 165 return qstrdup(nearest[state].keyword.toUtf8());
156 } 166 }
157 167