Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: Loaden on April 17, 2010, 06:35:56 am

Title: Patch for calltip
Post by: Loaden on April 17, 2010, 06:35:56 am
Code
Index: src/plugins/codecompletion/codecompletion.cpp

===================================================================

--- src/plugins/codecompletion/codecompletion.cpp (revision 6203)

+++ src/plugins/codecompletion/codecompletion.cpp (working copy)

@@ -2015,14 +2015,15 @@

             ShowCallTip();
 
         // start calltip
-        if (ch == _T('('))
+        if (ch == _T('(') || ch == _T(','))
         {
             if (control->CallTipActive())
                 ++m_ActiveCalltipsNest;
             ShowCallTip();
         }
+
         // end calltip
-        else if (ch == _T(')'))
+        else if (ch == _T(')') || ch == _T(';'))
         {
             // cancel any active calltip
             control->CallTipCancel();
Test demo:
Code
MessageBox(NULL, "TEST",
Title: Re: Patch for calltip
Post by: oBFusCATed on April 17, 2010, 03:43:34 pm
Testing it now, but had to regenerate it myself

Patch against clean trunk (works for the debugger branch too)
Code
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp       (revision 6202)
+++ src/plugins/codecompletion/codecompletion.cpp       (working copy)
@@ -2043,7 +2043,7 @@
             ShowCallTip();
 
         // start calltip
-        if (ch == _T('('))
+        if (ch == _T('(') || ch == _T(','))
         {
             if (control->CallTipActive())
                 ++m_ActiveCalltipsNest;
@@ -2051,7 +2051,7 @@
         }
 
         // end calltip
-        else if (ch == _T(')'))
+        else if (ch == _T(')') || ch == _T(';'))
         {
             // cancel any active calltip
             control->CallTipCancel();
Title: Re: Patch for calltip
Post by: Jenna on April 17, 2010, 04:03:19 pm
The patch has the same problem, then the original version, it ignores whether we are inside a string or not.
Title: Re: Patch for calltip
Post by: oBFusCATed on April 17, 2010, 05:22:15 pm
Also it doesn't fix the second time not showing bug :(

I'm not sure how to reproduce it 100%. But it is something like:
1. show the calltip for some function all (ctrl+shift+space)
2. do some editing
3. ctrl+shift+space stops working


Title: Re: Patch for calltip
Post by: Loaden on April 20, 2010, 07:04:41 am
The patch has the same problem, then the original version, it ignores whether we are inside a string or not.
Fix it now. and i fix a new problem.
example: MessageBoxA( // here, calltip not work )
Code
Index: src/plugins/codecompletion/codecompletion.cpp

===================================================================

--- src/plugins/codecompletion/codecompletion.cpp (revision 6203)

+++ src/plugins/codecompletion/codecompletion.cpp (working copy)

@@ -1996,8 +1996,7 @@

         }
     }
 
-    if (   (event.GetEventType() == wxEVT_SCI_CHARADDED)
-        && (!control->AutoCompActive()) ) // not already active autocompletion)
+    if (event.GetEventType() == wxEVT_SCI_CHARADDED)
     {
         // a character was just added in the editor
         m_TimerCodeCompletion.Stop();
@@ -2015,25 +2014,34 @@

             ShowCallTip();
 
         // start calltip
-        if (ch == _T('('))
+        if (ch == _T('(') || ch == _T(','))
         {
-            if (control->CallTipActive())
-                ++m_ActiveCalltipsNest;
-            ShowCallTip();
+            int style = control->GetStyleAt(control->GetCurrentPos() - 2);
+            if (style != wxSCI_C_STRING && style != wxSCI_C_COMMENT)
+            {
+                if (control->CallTipActive())
+                    ++m_ActiveCalltipsNest;
+                ShowCallTip();
+            }
         }
+
         // end calltip
-        else if (ch == _T(')'))
+        else if (ch == _T(')') || ch == _T(';'))
         {
-            // cancel any active calltip
-            control->CallTipCancel();
-            if (m_ActiveCalltipsNest > 0)
+            int style = control->GetStyleAt(control->GetCurrentPos() - 2);
+            if (style != wxSCI_C_STRING && style != wxSCI_C_COMMENT)
             {
-                --m_ActiveCalltipsNest;
-                ShowCallTip();
+                // cancel any active calltip
+                control->CallTipCancel();
+                if (m_ActiveCalltipsNest > 0)
+                {
+                    --m_ActiveCalltipsNest;
+                    ShowCallTip();
+                }
             }
         }
 
-        else if (    autoCC
+        else if (   (autoCC && !control->AutoCompActive()) // not already active autocompletion
                  || (ch == _T('"')) // this and the next one are for #include's completion
                  || (ch == _T('<'))
                  || (ch == _T('.'))

[attachment deleted by admin]