From 8069c1745ee3e60dd0d64d1a1c7e9d2ef779c212 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 14 Dec 2010 11:50:49 +0100
Subject: [PATCH] Don't popup the automatic completion box when the identifier
 under cursor is a complete valid word.

---
 src/plugins/cpptools/cppcodecompletion.cpp | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index e73e5451420..0f153b43f54 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -715,6 +715,31 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
 {
     int index = startCompletionHelper(editor);
     if (index != -1) {
+        if (m_automaticCompletion) {
+            const int pos = editor->position();
+            const QChar ch = editor->characterAt(pos);
+            if (! (ch.isLetterOrNumber() || ch == QLatin1Char('_'))) {
+                for (int i = pos - 1;; --i) {
+                    const QChar ch = editor->characterAt(i);
+                    if (ch.isLetterOrNumber() || ch == QLatin1Char('_')) {
+                        const QString wordUnderCursor = editor->textAt(i, pos - i);
+                        if (wordUnderCursor.at(0).isLetter() || wordUnderCursor.at(0) == QLatin1Char('_')) {
+                            foreach (const TextEditor::CompletionItem &i, m_completions) {
+                                if (i.text == wordUnderCursor) {
+                                    cleanup();
+                                    return -1;
+                                }
+                            }
+                        } else {
+                            cleanup();
+                            return -1;
+                        }
+                    } else
+                        break;
+                }
+            }
+        }
+
         if (m_completionOperator != T_EOF_SYMBOL)
             qSort(m_completions.begin(), m_completions.end(), completionItemLessThan);
 
-- 
GitLab