mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[performance tests] [undo] KTIJ-35540 check if action is applicable before executing
^KTIJ-35540 fixed GitOrigin-RevId: 7c876b7e71dba68caf3a9a1b1f332845952627e3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc9411f1f0
commit
535d73189c
-1
@@ -879,7 +879,6 @@ fun <T : CommandChain> T.cut(): T = apply {
|
||||
executeEditorAction("\$Cut")
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun <T : CommandChain> T.undo(): T = apply {
|
||||
executeEditorAction("\$Undo")
|
||||
}
|
||||
|
||||
+6
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user