Don't invoke setDone on rejected callback

GitOrigin-RevId: c48b66ff0172429dcd03b7d848384e094890049f
This commit is contained in:
Maxim.Kolmakov
2023-10-05 11:03:35 +02:00
committed by intellij-monorepo-bot
parent 78d15b5cdf
commit 6340d5ed29
2 changed files with 10 additions and 2 deletions

View File

@@ -94,6 +94,9 @@ public class ActionCallback implements Disposable {
}
}
/**
* You need to avoid calling #setDone() later on otherwise the rejection will be ignored
*/
public @NotNull ActionCallback reject(@NonNls String error) {
myError = error;
setRejected();

View File

@@ -68,7 +68,10 @@ public final class ShowAltEnter extends AbstractCommand implements Disposable {
span.setAttribute("number", combined.size());
Optional<IntentionActionWithTextCaching>
singleIntention = combined.stream().filter(s -> s.getAction().getText().startsWith(actionName)).findFirst();
if (singleIntention.isEmpty()) actionCallback.reject(actionName + " is not found among " + combined);
if (singleIntention.isEmpty()) {
actionCallback.reject(actionName + " is not found among " + combined);
return;
}
if (invoke) {
singleIntention.ifPresent(
c -> ShowIntentionActionsHandler.chooseActionAndInvoke(psiFile, editor, c.getAction(), c.getAction().getText()));
@@ -78,7 +81,9 @@ public final class ShowAltEnter extends AbstractCommand implements Disposable {
IntentionHintComponent.showIntentionHint(project, psiFile, editor, true, intentions);
}
});
actionCallback.setDone();
if(!actionCallback.isRejected()){
actionCallback.setDone();
}
}
else {
actionCallback.reject("PSI File is null");