From bd53a895c0a6dc51d37ed77e584168f899ca3824 Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Mon, 29 Jul 2024 16:54:02 +0200 Subject: [PATCH] Return nullability of editor in action --- .../java/com/maddyhome/idea/vim/helper/IjActionExecutor.kt | 7 +++++-- .../kotlin/com/maddyhome/idea/vim/api/VimActionExecutor.kt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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 cc8e8c551f..80184771f7 100644 --- a/src/main/java/com/maddyhome/idea/vim/helper/IjActionExecutor.kt +++ b/src/main/java/com/maddyhome/idea/vim/helper/IjActionExecutor.kt @@ -66,7 +66,7 @@ internal class IjActionExecutor : VimActionExecutor { * @param ijAction The action to execute * @param context The context to run it in */ - override fun executeAction(editor: VimEditor, action: NativeAction, context: ExecutionContext): Boolean { + override fun executeAction(editor: VimEditor?, action: NativeAction, context: ExecutionContext): Boolean { val ijAction = (action as IjNativeAction).action /** @@ -77,7 +77,10 @@ internal class IjActionExecutor : VimActionExecutor { dataContext.putUserData(runFromVimKey, true) val contextComponent = PlatformCoreDataKeys.CONTEXT_COMPONENT.getData(dataContext) - ?: editor.ij.component + ?: editor?.ij?.component ?: run { + LOG.error("Cannot get context component") + return false + } val result = withRunningAction { val result = withStringRegistryOption { diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimActionExecutor.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimActionExecutor.kt index 5c114a6fdf..2b9d58d8d6 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimActionExecutor.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimActionExecutor.kt @@ -27,7 +27,7 @@ interface VimActionExecutor { * @param action The action to execute * @param context The context to run it in */ - fun executeAction(editor: VimEditor, action: NativeAction, context: ExecutionContext): Boolean + fun executeAction(editor: VimEditor?, action: NativeAction, context: ExecutionContext): Boolean /** * Execute an action by name