diff --git a/src/main/java/com/maddyhome/idea/vim/helper/EditorDataContext.kt b/src/main/java/com/maddyhome/idea/vim/helper/EditorDataContext.kt index 1a88e4d2a1..cffb82668b 100644 --- a/src/main/java/com/maddyhome/idea/vim/helper/EditorDataContext.kt +++ b/src/main/java/com/maddyhome/idea/vim/helper/EditorDataContext.kt @@ -20,11 +20,13 @@ package com.maddyhome.idea.vim.helper import com.intellij.openapi.actionSystem.DataContext import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.editor.Editor +import com.intellij.openapi.util.Key +import com.intellij.openapi.util.UserDataHolder class EditorDataContext @Deprecated("Please use `init` method") constructor( private val editor: Editor, private val contextDelegate: DataContext? = null, -) : DataContext { +) : DataContext, UserDataHolder { /** * Returns the object corresponding to the specified data identifier. Some of the supported data identifiers are * defined in the [PlatformDataKeys] class. @@ -39,6 +41,20 @@ class EditorDataContext @Deprecated("Please use `init` method") constructor( else -> contextDelegate?.getData(dataId) } + override fun getUserData(key: Key): T? { + return if (contextDelegate is UserDataHolder) { + contextDelegate.getUserData(key) + } else { + null + } + } + + override fun putUserData(key: Key, value: T?) { + if (contextDelegate is UserDataHolder) { + contextDelegate.putUserData(key, value) + } + } + companion object { @Suppress("DEPRECATION") @JvmStatic