1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-10 12:34:06 +02:00

Use SimpleDataContext instead of the obsolete DataContextWrapper

This commit is contained in:
Alex Plate 2025-02-11 11:52:40 +02:00
parent 7eda176162
commit 4ca187926c
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 5 additions and 6 deletions
src/main/java/com/maddyhome/idea/vim

View File

@ -20,6 +20,7 @@ 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.actionSystem.impl.SimpleDataContext
import com.intellij.openapi.application.ex.ApplicationManagerEx
import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.command.UndoConfirmationPolicy
@ -83,8 +84,7 @@ internal class IjActionExecutor : VimActionExecutor {
* 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
*/
val dataContext = DataContextWrapper(context.ij)
dataContext.putUserData(runFromVimKey, true)
val dataContext = SimpleDataContext.getSimpleContext(runFromVimKey, true, context.ij)
val actionId = ActionManager.getInstance().getId(ijAction)
val event = AnActionEvent(

View File

@ -9,20 +9,19 @@
package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.UserDataHolder
import com.intellij.openapi.actionSystem.DataKey
import com.maddyhome.idea.vim.api.ExecutionContext
internal open class IjEditorExecutionContext(override val context: DataContext) : ExecutionContext
// This key is stored in data context when the action is started from vim
internal val runFromVimKey = Key.create<Boolean>("RunFromVim")
internal val runFromVimKey = DataKey.create<Boolean>("RunFromVim")
/**
* Check if the action with this data context was started from Vim
*/
internal val DataContext.actionStartedFromVim: Boolean
get() = (this as? UserDataHolder)?.getUserData(runFromVimKey) ?: false
get() = this.getData(runFromVimKey) == true
val DataContext.vim: ExecutionContext
get() = IjEditorExecutionContext(this)