From 535d73189c1f1facf8a6d1228eee94b21fbc742a Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 8 Sep 2025 09:06:32 +0200 Subject: [PATCH] [performance tests] [undo] KTIJ-35540 check if action is applicable before executing ^KTIJ-35540 fixed GitOrigin-RevId: 7c876b7e71dba68caf3a9a1b1f332845952627e3 --- .../ide/performanceTesting/commands/generalCommandChain.kt | 1 - .../commands/ExecuteEditorActionCommand.kt | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/performanceTesting/commands-model/src/com/intellij/tools/ide/performanceTesting/commands/generalCommandChain.kt b/plugins/performanceTesting/commands-model/src/com/intellij/tools/ide/performanceTesting/commands/generalCommandChain.kt index ea42ca194666..2a2312216c63 100644 --- a/plugins/performanceTesting/commands-model/src/com/intellij/tools/ide/performanceTesting/commands/generalCommandChain.kt +++ b/plugins/performanceTesting/commands-model/src/com/intellij/tools/ide/performanceTesting/commands/generalCommandChain.kt @@ -879,7 +879,6 @@ fun T.cut(): T = apply { executeEditorAction("\$Cut") } -@Suppress("unused") fun T.undo(): T = apply { executeEditorAction("\$Undo") } diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/ExecuteEditorActionCommand.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/ExecuteEditorActionCommand.kt index c44485e3e0f1..9dab583aa5c3 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/ExecuteEditorActionCommand.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/ExecuteEditorActionCommand.kt @@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.ex.ActionManagerEx.Companion.getInstanc import com.intellij.openapi.actionSystem.ex.ActionUtil import com.intellij.openapi.application.EDT import com.intellij.openapi.application.writeIntentReadAction +import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.ui.playback.PlaybackContext @@ -62,6 +63,11 @@ class ExecuteEditorActionCommand(text: String, line: Int) : PlaybackCommandCorou fun executeAction(editor: Editor, action: AnAction) { val event = AnActionEvent.createFromAnAction(action, null, "", createEditorContext(editor)) + ActionUtil.updateAction(action, event) + if (!event.presentation.isEnabled) { + Logger.getInstance(action::class.java).info("${action.javaClass.name} is disabled") + return + } val result = ActionUtil.performAction(action, event) if (!result.isPerformed) { throw IllegalStateException("Cant execute action $action")