# HG changeset patch # User Claus Gittinger # Date 1563208999 -7200 # Node ID 8670224f9fd5118bc747eaf447fc365984471810 # Parent 476a7030cebb0916b32cb0079feb2de92b257a09 #BUGFIX by cg class: EditTextViewCompletionSupport refactoring and fixes added: #computeAndShowCompletions changed: #startCompletionProcess diff -r 476a7030cebb -r 8670224f9fd5 EditTextViewCompletionSupport.st --- 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 " - "Modified: / 15-09-2018 / 12:40:59 / Claus Gittinger" + "Modified: / 15-07-2019 / 17:30:55 / Claus Gittinger" ! stopCompletionProcess