From 7105b773a12e8c0f79d31a9596f6c35b32d0bd08 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Thu, 8 Oct 2009 15:32:12 +0200
Subject: [PATCH] Enable completion in C++ ctor-initializers. For example,

struct foo {
  int m_zoo;

  foo(): m_ // cursor is here.
---
 src/plugins/cpptools/cppcodecompletion.cpp | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index aa071b73593..5e8df20ac08 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -640,6 +640,14 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
         }
     }
 
+    if (k == T_COMMA) {
+        ExpressionUnderCursor expressionUnderCursor;
+        if (expressionUnderCursor.startOfFunctionCall(tc) == -1) {
+            k = T_EOF_SYMBOL;
+            start = pos;
+        }
+    }
+
     static CPlusPlus::TokenUnderCursor tokenUnderCursor;
     const SimpleToken tk = tokenUnderCursor(tc);
 
@@ -783,11 +791,14 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
     if (m_completionOperator == T_COMMA) {
         tc.setPosition(endOfExpression);
         const int start = expressionUnderCursor.startOfFunctionCall(tc);
-        if (start != -1) {
-            endOfExpression = start;
-            m_startPosition = start + 1;
-            m_completionOperator = T_LPAREN;
+        if (start == -1) {
+            m_completionOperator = T_EOF_SYMBOL;
+            return -1;
         }
+
+        endOfExpression = start;
+        m_startPosition = start + 1;
+        m_completionOperator = T_LPAREN;
     }
 
     QString expression;
-- 
GitLab