[rd-editor] IJPL-191994 Fix for issue with speculative undo in two sides diff editor

(cherry picked from commit cccbb503ed49853a74589ea8454161c2794375b8)

IJ-CR-168712

GitOrigin-RevId: 3943e3d88faa1299db911adad3fd54bd21c5d961
This commit is contained in:
Alexander Trushev
2025-07-09 16:49:18 +02:00
committed by intellij-monorepo-bot
parent 11cfdd98de
commit 28df3ec03c

View File

@@ -6,6 +6,8 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehavior;
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.TextEditor;
@@ -19,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@ApiStatus.Internal
public final class ProxyUndoRedoAction extends DumbAwareAction {
public final class ProxyUndoRedoAction extends DumbAwareAction implements ActionRemoteBehaviorSpecification {
private final @NotNull UndoManager myUndoManager;
private final @NotNull TextEditor myEditor;
private final boolean myUndo;
@@ -45,6 +47,17 @@ public final class ProxyUndoRedoAction extends DumbAwareAction {
return ActionUpdateThread.EDT;
}
/**
* Forces backend only undo for diff editors.
* It is a hot fix for IJPL-191994.
* To support speculative (frontend) undo,
* it is necessary to find a proper fileEditorId that is not obvious in case of diff editors.
*/
@Override
public @NotNull ActionRemoteBehavior getBehavior() {
return ActionRemoteBehavior.BackendOnly;
}
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabled(myUndo ? myUndoManager.isUndoAvailable(myEditor) : myUndoManager.isRedoAvailable(myEditor));