#BUGFIX by cg
class: EditTextViewCompletionSupport
refactoring and fixes
added: #computeAndShowCompletions
changed: #startCompletionProcess
--- a/EditTextViewCompletionSupport.st Mon Jul 15 18:40:29 2019 +0200
+++ b/EditTextViewCompletionSupport.st Mon Jul 15 18:43:19 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:libwidg' }"
"{ NameSpace: Smalltalk }"
@@ -206,6 +208,14 @@
!EditTextViewCompletionSupport methodsFor:'private'!
+computeAndShowCompletions
+ "Actually compute the completions and update the completion view."
+
+ self subclassResponsibility
+
+ "Created: / 15-07-2019 / 17:29:50 / Claus Gittinger"
+!
+
computeCompletions
"Actually compute the completions and update the completion view."
@@ -226,8 +236,10 @@
|initialList cursorX cursorY p|
"/ terminate any previous process
- self stopCompletionProcess.
-
+ self synchronized:[
+ self stopCompletionProcess.
+ ].
+
(editView sensor hasKeyPressEventFor:nil) ifTrue:[
"/ 'cl' printCR.
self closeCompletionView.
@@ -259,12 +271,20 @@
Smalltalk isSmalltalkDevelopmentSystem ifTrue:[ ex reject ]
].
] do:[
+ |startTime|
+
+ startTime := Timestamp now.
+ "/ Wait a while to give user chance finish typing.
+ "/ This also reduces CPU consumption by avoiding
+ "/ useless computation
+ Delay waitForMilliseconds: 200.
+
(editView topView isDebugView) ifTrue:[
ControlInterrupt ignoreIn:[
- self computeCompletions.
+ self computeAndShowCompletions.
].
] ifFalse:[
- self computeCompletions.
+ self computeAndShowCompletions.
].
].
p == completionProcess ifTrue:[
@@ -281,7 +301,7 @@
p resume.
"Modified: / 26-09-2013 / 17:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 15-09-2018 / 12:40:59 / Claus Gittinger"
+ "Modified: / 15-07-2019 / 17:30:55 / Claus Gittinger"
!
stopCompletionProcess