From 9412b138b6e3fc29e7d1a8c378d83ffaf40b026b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com>
Date: Fri, 24 Jul 2009 14:32:39 +0200
Subject: [PATCH] Made trailing slash trigger the next include completion

The completion for the directory wasn't triggered because one of the
items matched the typed string, so the list of completion wasn't empty
and no new trigger was allowed.

By not matching items when a trailing slash is typed, the list is
allowed to trigger again from the new location.

Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
---
 src/plugins/cpptools/cppcodecompletion.cpp   | 6 ++++++
 src/plugins/texteditor/completionsupport.cpp | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index 8fac72b95ed..21085093cf5 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -1386,6 +1386,12 @@ void CppCodeCompletion::completions(QList<TextEditor::CompletionItem> *completio
     else if (length > 0) {
         const QString key = m_editor->textAt(m_startPosition, length);
 
+        /* Close on the trailing slash for include completion, to enable the slash to
+         * trigger a new completion list. */
+        if ((m_completionOperator == T_STRING_LITERAL ||
+             m_completionOperator == T_ANGLE_STRING_LITERAL) && key.endsWith(QLatin1Char('/')))
+            return;
+
         if (m_completionOperator != T_LPAREN) {
             /*
              * This code builds a regular expression in order to more intelligently match
diff --git a/src/plugins/texteditor/completionsupport.cpp b/src/plugins/texteditor/completionsupport.cpp
index 2938ed3afec..33bfed1e9e1 100644
--- a/src/plugins/texteditor/completionsupport.cpp
+++ b/src/plugins/texteditor/completionsupport.cpp
@@ -129,7 +129,7 @@ void CompletionSupport::autoComplete_helper(ITextEditable *editor, bool forced,
         m_startPosition = m_completionCollector->startCompletion(editor);
         completionItems = getCompletions();
 
-        QTC_ASSERT(m_startPosition != -1 || completionItems.size() == 0, return);
+        QTC_ASSERT(!(m_startPosition == -1 && completionItems.size() > 0), return);
 
         if (completionItems.isEmpty()) {
             cleanupCompletions();
-- 
GitLab