#UI_ENHANCEMENT by exept
authorClaus Gittinger <cg@exept.de>
Wed, 14 Aug 2019 16:45:59 +0200
changeset 6666 7aa9f3c69ba2
parent 6665 62d8ae630bcc
child 6667 af908df41a5e
#UI_ENHANCEMENT by exept class: EditTextViewCompletionSupport comment/format in: #handleKeyPress:x:y: changed: #postKeyPress:
EditTextViewCompletionSupport.st
--- a/EditTextViewCompletionSupport.st	Wed Aug 14 16:10:16 2019 +0200
+++ b/EditTextViewCompletionSupport.st	Wed Aug 14 16:45:59 2019 +0200
@@ -80,7 +80,7 @@
 handleKeyPress:key x:x y:y
     "return true, if I have eaten this keypress"
 
-    |ch completeImmediate eatCursorLeftOrRight eatCursorUpDown|
+    |ch eatCursorLeftOrRight eatCursorUpDown|
 
     "/ completeImmediate := UserPreferences current immediateCodeCompletion.
 
@@ -88,8 +88,10 @@
     (completionView notNil and:[completionView realized]) ifFalse:[
         editView hasSelection ifFalse:[
             ch := editView characterBeforeCursor.
+
             (ch notNil "/ i.e. not at begin of line
-            and:[ ch isLetterOrDigitOrUnderline ]) ifTrue:[
+              and:[ ch isLetterOrDigitOrUnderline ]
+            ) ifTrue:[
                 (key == #Control_L or:[ key == #Ctrl or:[ key == #Control_R or:[ key == #Control]]]) ifTrue:[
                     UserPreferences current codeCompletionOnControlKey ifTrue:[
                         autoSelect := true.
@@ -170,7 +172,7 @@
 !
 
 postKeyPress:key
-    |doComplete ch|
+    |doComplete ch w|
 
     UserPreferences current immediateCodeCompletion ifFalse:[
         "/ only update, if already open
@@ -179,6 +181,7 @@
 
     "/ (completionView notNil and:[completionView realized]) ifTrue:[^ self].
     editView hasSelection ifTrue:[^ self].
+
     ch := editView characterBeforeCursor.
     (ch notNil and:[ch isLetterOrDigitOrUnderline]) ifFalse:[^ self].
 
@@ -193,6 +196,15 @@
             "/ also on a separator, but only if at the end of a non-empty line
             doComplete := editView lineStringBeforeCursor withoutSeparators notEmpty.
         ].
+        doComplete ifTrue:[
+            w := editView wordBeforeCursor.
+            w isNil ifTrue:[
+                doComplete := false
+            ] ifFalse:[
+                "/ self halt.
+            ]
+        ].
+
         doComplete ifFalse:[
             self closeCompletionView
         ] ifTrue:[