1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-24 15:34:09 +02:00

Fix the issue that the shortcuts where not working in the command line

This commit is contained in:
Alex Plate 2025-01-29 10:11:23 +02:00
parent 610ef73d38
commit 6eeb0eb47d
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 12 additions and 14 deletions
src/main/java/com/maddyhome/idea/vim

View File

@ -14,10 +14,12 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.AnActionWrapper import com.intellij.openapi.actionSystem.AnActionWrapper
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.application.invokeLater import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.impl.EditorComponentImpl
import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.project.DumbAware import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.util.Key import com.intellij.openapi.util.Key
@ -36,7 +38,6 @@ import com.maddyhome.idea.vim.helper.HandlerInjector
import com.maddyhome.idea.vim.helper.inInsertMode import com.maddyhome.idea.vim.helper.inInsertMode
import com.maddyhome.idea.vim.helper.inNormalMode import com.maddyhome.idea.vim.helper.inNormalMode
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere 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.isPrimaryEditor
import com.maddyhome.idea.vim.helper.isTemplateActive import com.maddyhome.idea.vim.helper.isTemplateActive
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
@ -129,8 +130,8 @@ class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
) )
} }
} }
if (e.dataContext.isNotEditorContextComponent && Registry.`is`("ideavim.only.in.editor.component")) { if (e.dataContext.isNotSupportedContextComponent && Registry.`is`("ideavim.only.in.editor.component")) {
// Note: Currently, IdeaVim works ONLY in the editor component. However, the presence of the // Note: Currently, IdeaVim works ONLY in the editor & ExTextField component. However, the presence of the
// PlatformDataKeys.EDITOR in the data context does not mean that the current focused component is editor. // 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 // 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. // some time if no issues are found.
@ -399,4 +400,10 @@ private class ActionEnableStatus(
private enum class LogLevel { private enum class LogLevel {
DEBUG, INFO, ERROR, DEBUG, INFO, ERROR,
} }
private val DataContext.isNotSupportedContextComponent: Boolean
get() {
val contextComponent = this.getData(PlatformDataKeys.CONTEXT_COMPONENT) ?: return true
return contextComponent !is EditorComponentImpl && contextComponent !is ExTextField
}

View File

@ -11,12 +11,9 @@
package com.maddyhome.idea.vim.helper package com.maddyhome.idea.vim.helper
import com.intellij.codeWithMe.ClientId 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.Caret
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.ex.util.EditorUtil 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.openapi.fileEditor.ex.FileEditorManagerEx
import com.intellij.util.ui.table.JBTableRowEditor import com.intellij.util.ui.table.JBTableRowEditor
import com.maddyhome.idea.vim.api.StringListOptionValue import com.maddyhome.idea.vim.api.StringListOptionValue
@ -100,10 +97,4 @@ internal val Caret.vimLine: Int
* Get current caret line in vim notation (1-based) * Get current caret line in vim notation (1-based)
*/ */
internal val Editor.vimLine: Int internal val Editor.vimLine: Int
get() = this.caretModel.currentCaret.vimLine get() = this.caretModel.currentCaret.vimLine
internal val DataContext.isNotEditorContextComponent: Boolean
get() {
val contextComponent = this.getData(PlatformDataKeys.CONTEXT_COMPONENT) ?: return true
return contextComponent !is EditorComponentImpl
}