From 8d5df1137263c2ef843b4f17668cbbbc21fd54af Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Wed, 31 Jul 2024 15:13:04 +0300 Subject: [PATCH] Add a warning when the action is executed from the write action Related: VIM-3376 --- .../com/maddyhome/idea/vim/helper/IjActionExecutor.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/maddyhome/idea/vim/helper/IjActionExecutor.kt b/src/main/java/com/maddyhome/idea/vim/helper/IjActionExecutor.kt index 0719a08eac..b166c8f3f3 100644 --- a/src/main/java/com/maddyhome/idea/vim/helper/IjActionExecutor.kt +++ b/src/main/java/com/maddyhome/idea/vim/helper/IjActionExecutor.kt @@ -20,10 +20,13 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.actionSystem.ex.ActionUtil import com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks import com.intellij.openapi.actionSystem.impl.ProxyShortcutSet +import com.intellij.openapi.application.ex.ApplicationManagerEx import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.command.UndoConfirmationPolicy import com.intellij.openapi.components.Service +import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.editor.actionSystem.DocCommandGroupId +import com.intellij.openapi.progress.util.ProgressIndicatorUtils import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.util.NlsContexts import com.maddyhome.idea.vim.RegisterActions @@ -65,6 +68,12 @@ internal class IjActionExecutor : VimActionExecutor { * @param context The context to run it in */ override fun executeAction(editor: VimEditor?, action: NativeAction, context: ExecutionContext): Boolean { + val applicationEx = ApplicationManagerEx.getApplicationEx() + if (ProgressIndicatorUtils.isWriteActionRunningOrPending(applicationEx)) { + // This is needed for VIM-3376 and it should turn into error at soeme moment + thisLogger().warn(RuntimeException("Actions cannot be updated when write-action is running or pending", )) + } + val ijAction = (action as IjNativeAction).action /**