don't async-render invalid lookup elements (EA-231917 - PIEAE)

GitOrigin-RevId: f44dfedd7347a697f175adaf60468281b717f2f5
This commit is contained in:
Peter Gromov
2020-06-16 16:16:17 +03:00
committed by intellij-monorepo-bot
parent 9ed5b5bd74
commit 06ff544f9d
@@ -59,7 +59,14 @@ public class AsyncRendering {
Ref<CancellablePromise<?>> promiseRef = Ref.create();
CancellablePromise<Void> promise = ReadAction
.nonBlocking(() -> renderInBackground(element, renderer, promiseRef))
.nonBlocking(() -> {
if (element.isValid()) {
renderInBackground(element, renderer);
}
synchronized (LAST_COMPUTATION) {
element.replace(LAST_COMPUTATION, promiseRef.get(), null);
}
})
.expireWith(myLookup)
.submit(ourExecutor);
element.putUserData(LAST_COMPUTATION, promise);
@@ -68,7 +75,7 @@ public class AsyncRendering {
}
@SuppressWarnings({"rawtypes", "unchecked"})
private void renderInBackground(LookupElement element, LookupElementRenderer renderer, Ref<CancellablePromise<?>> promiseRef) {
private void renderInBackground(LookupElement element, LookupElementRenderer renderer) {
LookupElementPresentation presentation = new LookupElementPresentation();
FileBasedIndex.getInstance().ignoreDumbMode(() -> {
renderer.renderElement(element, presentation);
@@ -76,10 +83,6 @@ public class AsyncRendering {
rememberPresentation(element, presentation);
scheduleLookupUpdate(element, presentation);
synchronized (LAST_COMPUTATION) {
element.replace(LAST_COMPUTATION, promiseRef.get(), null);
}
}
private void scheduleLookupUpdate(LookupElement element, LookupElementPresentation presentation) {