From cb4255e2ca40f8e54ad9c3720a8cfbb0aef4274e Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Thu, 4 Sep 2025 16:16:38 +0200 Subject: [PATCH] IJPL-199180 don't show lookup if the current phase is different GitOrigin-RevId: 4729d66ff5cdbaded4ff77aff20b2546a2a4add6 --- .../codeInsight/completion/CompletionPhase.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.kt b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.kt index 7475755d62a4..98d4e44bc37d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.kt @@ -256,6 +256,11 @@ sealed class CompletionPhase @ApiStatus.Internal constructor( ) { LOG.trace { "Finish on UI thread :: completionEditor=$completionEditor" } + if (phase != CompletionServiceImpl.completionPhase) { + LOG.trace { "Phase is expired :: myPhase=${phase}, completionPhase=${CompletionServiceImpl.completionPhase} " } + return + } + if (phase.myState !is InProgress) { LOG.trace { "Phase is expired :: myState=${phase.myState}" } return @@ -265,24 +270,19 @@ sealed class CompletionPhase @ApiStatus.Internal constructor( // preparation has failed for this specific request. We must cancel only this request. // If no other requests are pending, we can cancel the phase altogether. - if (phase == CompletionServiceImpl.completionPhase) { - LOG.trace { "Setting NoCompletion phase :: completionEditor=$completionEditor, expirationReason=editor is null" } - phase.cancelThisRequest() - if (phase.myState == Cancelled) { - CompletionServiceImpl.setCompletionPhase(NoCompletion) - } + LOG.trace { "Setting NoCompletion phase :: completionEditor=$completionEditor, expirationReason=editor is null" } + phase.cancelThisRequest() + if (phase.myState == Cancelled) { + CompletionServiceImpl.setCompletionPhase(NoCompletion) } return } if (phase.myTracker.hasAnythingHappened()) { // activity has happened in the editor. We must cancel all the requests altogether - - if (phase == CompletionServiceImpl.completionPhase) { - LOG.trace { "Setting NoCompletion phase :: completionEditor=$completionEditor, expirationReason=${phase.myTracker.describeChangeEvent()}" } - phase.cancelPhase() - CompletionServiceImpl.setCompletionPhase(NoCompletion) - } + LOG.trace { "Setting NoCompletion phase :: completionEditor=$completionEditor, expirationReason=${phase.myTracker.describeChangeEvent()}" } + phase.cancelPhase() + CompletionServiceImpl.setCompletionPhase(NoCompletion) return }