1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-02-17 14:46:03 +01:00

Fix(VIM-3615): Escape closes dialog while waiting for more keys

This commit is contained in:
chylex 2024-08-25 09:07:59 +02:00
parent 0f7116b136
commit fdd850de5a
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
2 changed files with 12 additions and 5 deletions
src/main/java/com/maddyhome/idea/vim/handler
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/command

View File

@ -218,13 +218,17 @@ internal class VimEnterHandler(nextHandler: EditorActionHandler?) : VimKeyHandle
internal class VimEscHandler(nextHandler: EditorActionHandler) : VimKeyHandler(nextHandler) {
override val key: String = "<Esc>"
private val ideaVimSupportDialog
get() = injector.globalIjOptions().ideavimsupport.contains(IjOptionConstants.ideavimsupport_dialog)
override fun isHandlerEnabled(editor: Editor, dataContext: DataContext?): Boolean {
val ideaVimSupportDialog =
injector.globalIjOptions().ideavimsupport.contains(IjOptionConstants.ideavimsupport_dialog)
return editor.isPrimaryEditor() ||
EditorHelper.isFileEditor(editor) && !editor.vim.mode.inNormalMode ||
ideaVimSupportDialog && !editor.vim.mode.inNormalMode
EditorHelper.isFileEditor(editor) && vimStateNeedsToHandleEscape(editor) ||
ideaVimSupportDialog && vimStateNeedsToHandleEscape(editor)
}
private fun vimStateNeedsToHandleEscape(editor: Editor): Boolean {
return !editor.vim.mode.inNormalMode || KeyHandler.getInstance().keyHandlerState.mappingState.hasKeys
}
}

View File

@ -37,6 +37,9 @@ class MappingState: Cloneable {
val keys: Iterable<KeyStroke>
get() = keyList
val hasKeys
get() = keyList.isNotEmpty()
private var timer = VimTimer(injector.globalOptions().timeoutlen)
private var keyList = mutableListOf<KeyStroke>()