--- a/EditTextViewCompletionSupport.st Tue Sep 01 18:58:40 2015 +0200
+++ b/EditTextViewCompletionSupport.st Thu Sep 03 09:04:45 2015 +0200
@@ -1,5 +1,9 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:libwidg' }"
+"{ NameSpace: Smalltalk }"
+
Object subclass:#EditTextViewCompletionSupport
instanceVariableNames:'completionView completionProcess editView autoSelect'
classVariableNames:'LastCompletions'
@@ -76,13 +80,13 @@
|ch completeImmediate eatCursorLeftOrRight eatCursorUpDown|
- completeImmediate := UserPreferences current immediateCodeCompletion.
+ "/ completeImmediate := UserPreferences current immediateCodeCompletion.
"/ open on CTRL- or TAB-key?
(completionView isNil or:[completionView realized not]) ifTrue:[
editView hasSelection ifFalse:[
((ch := editView characterBeforeCursor) notNil "/ i.e. not at begin of line
- and:[ ch isLetterOrDigit or:[ch == $_] ]) ifTrue:[
+ and:[ ch isLetterOrDigit or:[ '_' includes:ch ] ]) ifTrue:[
(key == #Control_L or:[ key == #Ctrl or:[ key == #Control_R or:[ key == #Control]]]) ifTrue:[
UserPreferences current codeCompletionOnControlKey ifTrue:[
autoSelect := true.
@@ -153,6 +157,8 @@
!
postKeyPress:key
+ |doComplete|
+
UserPreferences current immediateCodeCompletion ifFalse:[
"/ only update, if already open
completionView isNil ifTrue:[^ self].
@@ -165,9 +171,13 @@
].
key isCharacter ifTrue:[
- key isSeparator ifTrue:[
+ (doComplete := key isSeparator not) ifFalse:[
+ "/ also on a separator, but only if at the end of a non-empty line
+ doComplete := editView lineStringBeforeCursor withoutSeparators notEmpty.
+ ].
+ doComplete ifFalse:[
self closeCompletionView
- ] ifFalse:[
+ ] ifTrue:[
autoSelect := false.
self updateCompletionList.
].
@@ -313,13 +323,14 @@
"Created: / 26-09-2013 / 17:07:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!EditTextViewCompletionSupport class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextViewCompletionSupport.st,v 1.10 2014-06-14 11:18:07 cg Exp $'
+ ^ '$Header$'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextViewCompletionSupport.st,v 1.10 2014-06-14 11:18:07 cg Exp $'
+ ^ '$Header$'
! !