mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-07 13:34:02 +02:00
[VIM-3376] Add a new way of executing the action
This commit is contained in:
parent
b3631b59ed
commit
8483e23ea7
src/main
java/com/maddyhome/idea/vim
resources/META-INF
@ -32,6 +32,7 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.api.key
|
||||
import com.maddyhome.idea.vim.group.IjOptionConstants
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.IjActionExecutor
|
||||
import com.maddyhome.idea.vim.helper.inNormalMode
|
||||
import com.maddyhome.idea.vim.helper.isPrimaryEditor
|
||||
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
|
||||
@ -169,6 +170,7 @@ internal abstract class OctopusHandler(private val nextHandler: EditorActionHand
|
||||
}
|
||||
|
||||
if (dataContext?.actionStartedFromVim == true) return true
|
||||
if ((injector.actionExecutor as? IjActionExecutor)?.isRunningActionFromVim == true) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ 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.intellij.openapi.util.registry.Registry
|
||||
import com.maddyhome.idea.vim.RegisterActions
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.NativeAction
|
||||
@ -65,6 +66,8 @@ internal class IjActionExecutor : VimActionExecutor {
|
||||
// [VERSION UPDATE] 2024.3+ Replace raw "ExpandCollapseToggleAction" with IdeActions.ACTION_EXPAND_COLLAPSE_TOGGLE_REGION from the platform.
|
||||
get() = "ExpandCollapseToggleAction"
|
||||
|
||||
var isRunningActionFromVim: Boolean = false
|
||||
|
||||
/**
|
||||
* Execute an action
|
||||
*
|
||||
@ -79,7 +82,23 @@ internal class IjActionExecutor : VimActionExecutor {
|
||||
}
|
||||
|
||||
val ijAction = (action as IjNativeAction).action
|
||||
if (Registry.`is`("ideavim.old.action.execution", true)) {
|
||||
return manualActionExecution(context, ijAction)
|
||||
} else {
|
||||
try {
|
||||
isRunningActionFromVim = true
|
||||
val res = ActionManager.getInstance().tryToExecute(ijAction, null, editor?.ij?.component, "IdeaVim", true)
|
||||
return res.isDone
|
||||
} finally {
|
||||
isRunningActionFromVim = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun manualActionExecution(
|
||||
context: ExecutionContext,
|
||||
ijAction: AnAction,
|
||||
): Boolean {
|
||||
/**
|
||||
* Data context that defines that some action was started from IdeaVim.
|
||||
* You can call use [runFromVimKey] key to define if intellij action was started from IdeaVim
|
||||
|
@ -133,6 +133,8 @@
|
||||
implementation="com.maddyhome.idea.vim.listener.VimListenerManager$VimDocumentListener"/>
|
||||
<registryKey defaultValue="true" description="Enable IdeaVim only in editor component and project tree"
|
||||
key="ideavim.only.in.editor.component"/>
|
||||
<registryKey defaultValue="true" description="Old action execution mechanism" key="ideavim.old.action.execution"
|
||||
restartRequired="false"/>
|
||||
</extensions>
|
||||
|
||||
<xi:include href="/META-INF/includes/ApplicationServices.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
|
Loading…
Reference in New Issue
Block a user