diff options
-rw-r--r-- | akonadi2_cli/repl/replStates.cpp | 16 |
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 | ||
150 | static char *akonadi2_cli_next_tab_complete_match(const char *text, int state) | 150 | static 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 | ||