From d1fe69e7882f7dbc7183ce8827c80ebc5e93283e Mon Sep 17 00:00:00 2001 From: "peter.gromov" Date: Wed, 10 Nov 2010 21:14:27 +0300 Subject: [PATCH] if I invoked another completion instance, the previous one should be canceled, and not restarted --- .../completion/CompletionProgressIndicator.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index a4391c524793..629c37434e2a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -88,7 +88,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement }; private LightweightHint myHint; private final Semaphore myFreezeSemaphore; - private boolean myToRestart; + private Boolean myToRestart; private boolean myModifiersReleased; @@ -436,6 +436,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } private void finishCompletionProcess() { + assert myToRestart == null; + myToRestart = false; cancel(); assert !myDisposed; @@ -474,7 +476,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement invokeLaterIfNotDispatch(new Runnable() { public void run() { if (isOutdated()) return; - if (isCanceled() && !myToRestart) return; // otherwise + if (isCanceled() && myToRestart != Boolean.TRUE) return; //what if a new completion was invoked by the user before this 'later'? if (CompletionProgressIndicator.this != CompletionServiceImpl.getCompletionService().getCurrentCompletion()) return; @@ -528,6 +530,11 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } public void cancelByWriteAction() { + if (myToRestart != null) { + assert myToRestart == Boolean.FALSE; //explicit completionFinished was invoked before this write action + return; + } + myToRestart = true; cancel(); @@ -605,7 +612,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } public void prefixUpdated() { - if (myToRestart) { + if (myToRestart == Boolean.TRUE) { scheduleRestart(); return; }