View unanswered posts | View active topics



Reply to topic  [ 3 posts ] 
Ctrl+Space forces new completion 
Author Message
Member

Joined: Thu Feb 02, 2012 5:59 pm
Posts: 78
Location: Alabama
Reply with quote
In my daily work I use a lot a Controller classes that expose static methods. The code completion, as it is, does not make this easy for me as I have to type 'new {className}' in order to get the completion to show the controller class. I then have to delete 'new' after completing the class name.

This patch changes the ASCompletion plugin to pass a flag that forces showing the new completion when ctrl+space is used to bring up the completion dropdown. The logic is a fallback and should only fire if it is not determined to be a new, imports, or colon completion.

Thanks

Code:
Index: Completion/ASComplete.cs
===================================================================
--- Completion/ASComplete.cs   (revision 2205)
+++ Completion/ASComplete.cs   (working copy)
@@ -60,7 +60,7 @@
       /// Character written in editor
       /// </summary>
       /// <param name="Value">Character inserted</param>
-      static public bool OnChar(ScintillaControl Sci, int Value, bool autoHide)
+      static public bool OnChar(ScintillaControl Sci, int Value, bool autoHide, bool forceNewCompletion)
       {
             IASContext ctx = ASContext.Context;
          if (ctx.Settings == null || !ctx.Settings.CompletionEnabled)
@@ -107,12 +107,12 @@
             {
                case '.':
                         if (features.dot == "." || !autoHide)
-                            return HandleDotCompletion(Sci, autoHide);
+                            return HandleDotCompletion(Sci, autoHide, forceNewCompletion);
                         break;
 
                     case '>':
                         if (features.dot == "->" && Sci.CharAt(position - 2) == '-')
-                            return HandleDotCompletion(Sci, autoHide);
+                            return HandleDotCompletion(Sci, autoHide, forceNewCompletion);
                         break;
 
                     case ' ':
@@ -293,7 +293,7 @@
                 if (ASContext.HasContext && ASContext.Context.IsFileValid)
             {
                // force dot completion
-                    OnChar(Sci, '.', false);
+                    OnChar(Sci, '.', false, true);
                return true;
             }
             else return false;
@@ -305,7 +305,7 @@
             {
                //HandleFunctionCompletion(Sci);
                     // force function completion
-                    OnChar(Sci, '(', false);
+                    OnChar(Sci, '(', false, false);
                return true;
             }
             else return false;
@@ -430,7 +430,7 @@
                         }
                         c2 = c;
                     }
-                    if (canComplete) HandleDotCompletion(Sci, true);
+                    if (canComplete) HandleDotCompletion(Sci, true, false);
                 }
             }
         }
@@ -1671,7 +1671,7 @@
       /// <param name="Sci">Scintilla control</param>
       /// <param name="autoHide">Don't keep the list open if the word does not match</param>
       /// <returns>Auto-completion has been handled</returns>
-      static private bool HandleDotCompletion(ScintillaControl Sci, bool autoHide)
+      static private bool HandleDotCompletion(ScintillaControl Sci, bool autoHide, bool forceNewCompletion)
       {
             //this method can exit at multiple points, so reset the current class now rather than later
             currentClassHash = null;
@@ -1767,6 +1767,11 @@
                 return true;
             }
 
+            if (forceNewCompletion)
+            {
+                return HandleNewCompletion(Sci, expr.Value, autoHide, word);
+            }
+
             // Context
             ASResult result;
             ClassModel tmpClass;
Index: PluginMain.cs
===================================================================
--- PluginMain.cs   (revision 2205)
+++ PluginMain.cs   (working copy)
@@ -820,7 +820,7 @@
       private void OnChar(ScintillaNet.ScintillaControl Sci, int Value)
       {
          if (Sci.Lexer == 3 || Sci.Lexer == 4)
-            ASComplete.OnChar(Sci, Value, true);
+            ASComplete.OnChar(Sci, Value, true, false);
       }
 
       private void OnMouseHover(ScintillaNet.ScintillaControl sci, int position)



Thu Feb 02, 2012 6:10 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
Great to see people hacking FD code ;)

You can also type Ctrl+Alt+Space to display the same completion list as you get after 'new' or ':'. Isn't that enough?


Thu Feb 02, 2012 10:12 pm
Profile WWW
Member

Joined: Thu Feb 02, 2012 5:59 pm
Posts: 78
Location: Alabama
Reply with quote
Doh! Seems that I should read the manual first.

Thanks. =)


Fri Feb 03, 2012 9:57 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.