SmallSense__CompletionController.st
changeset 153 b04d591c8788
parent 143 038fdc3940f3
child 154 b96fbde91144
--- a/SmallSense__CompletionController.st	Wed Dec 18 00:03:23 2013 +0100
+++ b/SmallSense__CompletionController.st	Sat Jan 18 22:56:44 2014 +0000
@@ -142,44 +142,6 @@
     "Modified: / 17-10-2013 / 01:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-startCompletionProcess
-    "start the code completion process in the background"
-
-    |initialList cursorX cursorY|
-
-    "/ terminate any previous process
-    self stopCompletionProcess.
-
-    (editView sensor hasKeyPressEventFor:nil) ifTrue:[ 
-        "/ 'cl' printCR.
-        self closeCompletionView. 
-        ^ self
-    ].
-    ((cursorX := editView xOfCursor) isNil
-    or:[ (cursorY := editView yOfCursor) isNil ]) ifTrue:[
-        "/ no cursor - user is selecting, or cursor has been scrolled out of sight.
-        "/ 'cl2' printCR.
-        self closeCompletionView. 
-        ^ self
-    ].
-
-    completionView isNil ifTrue:[
-        initialList := #( ).
-        "/ 'op1' printCR.
-    ] ifFalse:[
-        initialList := completionView list.
-        "/ 'op2' printCR.
-    ].
-    self openCompletionView:initialList.
-
-    completionProcess := 
-        [
-            self computeCompletions.
-        ] forkAt:(Processor activePriority - 1).
-
-    "Created: / 04-11-2013 / 11:55:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 stopCompletionProcess
     "kill any background completion process"
 
@@ -210,16 +172,17 @@
     word := support wordBeforeCursor.
     matches := completionView list select:[:po | po stringToComplete startsWith: word ].
     matches notEmptyOrNil ifTrue:[
-        completionView selection: (matches inject: matches anElement into:[:shortest :each |
-            each stringToComplete size < shortest stringToComplete size 
+        completionView selection: (matches inject: matches anElement into:[:mostrelevant :each |
+            each relevance > mostrelevant relevance 
                 ifTrue:[each]
-                ifFalse:[shortest]
+                ifFalse:[mostrelevant]
         ]).
     ] ifFalse:[
         completionView selection: nil.
-    ]
+    ].
 
     "Created: / 27-09-2013 / 16:16:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-01-2014 / 22:51:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CompletionController methodsFor:'private-API'!
@@ -274,6 +237,7 @@
     "/ move the window
 
     list isEmpty ifTrue:[ ^ self ].
+    list = #( 'Busy...' ) ifTrue:[ ^ self ].  
 
     x := (editView xOfCol:editView cursorCol  inVisibleLine:editView cursorLine)
             - 16"icon" - (editView widthOfString:  support wordBeforeCursor) - 5"magic constant".
@@ -307,7 +271,7 @@
     ].
 
     "Created: / 27-09-2013 / 14:01:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 03-10-2013 / 07:10:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-01-2014 / 22:23:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 updateCompletions: completionResult sequence: sequence