Skip to content

Commit

Permalink
Wrap quick fix invocations in a 'command'
Browse files Browse the repository at this point in the history
Wrap quick fix invocations in a command to allow undo. This should have
been done by the IDE, but based on recent bug reports, it is not.

Fixes #160, #161
  • Loading branch information
opwvhk committed Aug 18, 2024
1 parent c51e869 commit 786731a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
import com.intellij.codeInspection.util.IntentionFamilyName;
import com.intellij.codeInspection.util.IntentionName;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.CaretState;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
Expand Down Expand Up @@ -57,14 +58,16 @@ public boolean isAvailable(@NotNull Project project, @NotNull PsiFile file, @Not
@SuppressWarnings("unchecked")
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement,
@NotNull PsiElement endElement) {
invoke(project, file, (Editor) null, (E) startElement);
CommandProcessor.getInstance().executeCommand(project,
() -> invoke(project, file, (Editor) null, (E) startElement), text, null);
}

@Override
@SuppressWarnings("unchecked")
public void invoke(@NotNull Project project, @NotNull PsiFile file, @Nullable Editor editor,
@NotNull PsiElement startElement, @NotNull PsiElement endElement) {
invoke(project, file, editor, (E) startElement);
CommandProcessor.getInstance().executeCommand(project,
() -> invoke(project, file, editor, (E) startElement), text, null);
}

protected void selectElement(Editor editor, @NotNull PsiElement element) {
Expand Down

0 comments on commit 786731a

Please sign in to comment.