[highlighting] lazy quick fixes: handle cancel of explicit progress after alt-enter

- lazy fixes are calculated after highlighting is ready. When a user presses alt-enter results might be not yet calculated, and we would wait for already started calculation under new progress. Cancellation of this new progress doesn't stop an existing calculation because it was started with another progress. As a result, we have a progress which can't be really cancelled.
- this fix leaves existing calculations to complete and start a new one under the current progress instead. It's possibly a waste of some resources, but the initial calculation already precached a lot of things, so the second calculation should be fast.

^KTIJ-33154 fixed


(cherry picked from commit 0100c51ec6089c3a46dc67aebe74ecda1162fb70)

IJ-CR-166824

GitOrigin-RevId: 5887456e910922eb0839c6557874df4ee1ef3041
This commit is contained in:
Anna Kozlova
2025-06-24 10:48:46 +02:00
committed by intellij-monorepo-bot
parent bd02fd1fa0
commit 6defef767a

View File

@@ -1362,7 +1362,9 @@ public class HighlightInfo implements Segment {
} }
List<LazyFixDescription> newPairs = ContainerUtil.map(pairs, desc -> { List<LazyFixDescription> newPairs = ContainerUtil.map(pairs, desc -> {
Future<? extends List<IntentionActionDescriptor>> future = desc.future(); Future<? extends List<IntentionActionDescriptor>> future = desc.future();
if (future == null) { if (future == null || !future.isDone()) {
// if the existing fixture computation is not ready yet
// it's under another progress and cancellation won't work
Consumer<? super QuickFixActionRegistrar> computer = desc.fixesComputer(); Consumer<? super QuickFixActionRegistrar> computer = desc.fixesComputer();
future = CompletableFuture.completedFuture(doComputeLazyQuickFixes(document, psiFile.getProject(), desc.psiModificationStamp(), computer)); future = CompletableFuture.completedFuture(doComputeLazyQuickFixes(document, psiFile.getProject(), desc.psiModificationStamp(), computer));
return new LazyFixDescription(computer, desc.psiModificationStamp(), future); return new LazyFixDescription(computer, desc.psiModificationStamp(), future);