diff options
author | Mickael Istria | 2019-12-12 08:09:42 +0000 |
---|---|---|
committer | Mickael Istria | 2019-12-12 09:49:24 +0000 |
commit | 049ef41111aa28b068b62d6e6385e664a96472b9 (patch) | |
tree | c45ec3865ff0f29e60096118ccaa516397309e88 | |
parent | 53921d098c5aaa810e52e3b3a2cd702e64fffdf5 (diff) | |
download | eclipse.platform.text-049ef41111aa28b068b62d6e6385e664a96472b9.tar.gz eclipse.platform.text-049ef41111aa28b068b62d6e6385e664a96472b9.tar.xz eclipse.platform.text-049ef41111aa28b068b62d6e6385e664a96472b9.zip |
Bug 553577 - [Async completion] avoid NPEY20191217-0600I20191219-1800I20191218-1805I20191218-0015I20191217-1800I20191216-1805I20191215-1800I20191214-1800I20191213-1805I20191213-0155I20191212-1800
fComputedProposals can be changed or reset to null by other operations.
Add a check that fComputedProposals is still "bound" to current
computation before applying results.
Change-Id: If924044693dfc34013a0b9919f26c64049d6c947
Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java index ce724dd973f..e39bc2f3043 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java @@ -224,16 +224,18 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup { fComputedProposals.add(0, computingProposal); setProposals(fComputedProposals, false); AtomicInteger remaining= new AtomicInteger(populateFutures.size()); + final List<ICompletionProposal> requestSpecificProposals= fComputedProposals; //fComputedProposals can be changed/reset later populateFutures= populateFutures.stream().map(future -> future.thenRun(() -> { computingProposal.setRemaining(remaining.decrementAndGet()); if (remaining.get() == 0) { - fComputedProposals.remove(computingProposal); + requestSpecificProposals.remove(computingProposal); } Control control= fContentAssistSubjectControlAdapter.getControl(); if (!control.isDisposed() && offset == fInvocationOffset) { control.getDisplay().asyncExec(() -> { - // Don't run anything if offset has changed while runnable was scheduled (i.e. filtering might have occurred for fast CA) - if (offset != fInvocationOffset) { + // Skip if offset has changed while runnable was scheduled + // nor when completion "session" was modified or canceled. + if (offset != fInvocationOffset || fComputedProposals != requestSpecificProposals) { return; } if (autoInsert |