mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-04 16:34:02 +02:00
Fix(VIM-3640): Enable IdeaVim only in the editor context component
As the GitHub Copilot is placed right in the editor component, the IdeaVim's actions are also collected. Action promoter promotes the IdeaVim's action and, since the data context has the editor, executes a Vim's actions like backspace. Now we make sure that IdeaVim works only in the actual editor. Since this change may affect some places where the IdeaVim used to work, but won't work now (this will be a surprise), a registry key is introduced to help the users that face this problem.
This commit is contained in:
parent
7573d83898
commit
e358dc9cee
src/main
java/com/maddyhome/idea/vim
resources/META-INF
@ -21,6 +21,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.ui.KeyStrokeAdapter
|
||||
import com.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
@ -35,6 +36,7 @@ import com.maddyhome.idea.vim.helper.HandlerInjector
|
||||
import com.maddyhome.idea.vim.helper.inInsertMode
|
||||
import com.maddyhome.idea.vim.helper.inNormalMode
|
||||
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
|
||||
import com.maddyhome.idea.vim.helper.isNotEditorContextComponent
|
||||
import com.maddyhome.idea.vim.helper.isPrimaryEditor
|
||||
import com.maddyhome.idea.vim.helper.isTemplateActive
|
||||
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
|
||||
@ -127,6 +129,13 @@ class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
|
||||
)
|
||||
}
|
||||
}
|
||||
if (e.dataContext.isNotEditorContextComponent && Registry.`is`("ideavim.only.in.editor.component")) {
|
||||
// Note: Currently, IdeaVim works ONLY in the editor component. However, the presence of the
|
||||
// PlatformDataKeys.EDITOR in the data context does not mean that the current focused component is editor.
|
||||
// Note2: The registry key is needed for quick disabling in case something gets broken. It can be removed after
|
||||
// some time if no issues are found.
|
||||
return ActionEnableStatus.no("Context component is not editor", LogLevel.INFO)
|
||||
}
|
||||
if (editor.isIdeaVimDisabledHere) {
|
||||
return ActionEnableStatus.no("IdeaVim is disabled in this place", LogLevel.INFO)
|
||||
}
|
||||
|
@ -11,9 +11,12 @@
|
||||
package com.maddyhome.idea.vim.helper
|
||||
|
||||
import com.intellij.codeWithMe.ClientId
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil
|
||||
import com.intellij.openapi.editor.impl.EditorComponentImpl
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
import com.intellij.util.ui.table.JBTableRowEditor
|
||||
import com.maddyhome.idea.vim.api.StringListOptionValue
|
||||
@ -98,3 +101,9 @@ internal val Caret.vimLine: Int
|
||||
*/
|
||||
internal val Editor.vimLine: Int
|
||||
get() = this.caretModel.currentCaret.vimLine
|
||||
|
||||
internal val DataContext.isNotEditorContextComponent: Boolean
|
||||
get() {
|
||||
val contextComponent = this.getData(PlatformDataKeys.CONTEXT_COMPONENT) ?: return true
|
||||
return contextComponent !is EditorComponentImpl
|
||||
}
|
@ -131,6 +131,8 @@
|
||||
order="first"/>
|
||||
<editorFactoryDocumentListener
|
||||
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"/>
|
||||
</extensions>
|
||||
|
||||
<xi:include href="/META-INF/includes/ApplicationServices.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
|
Loading…
Reference in New Issue
Block a user