mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-10 06:40:37 +02:00
Checking whether current mode is command before entering insert mode
This commit is contained in:
parent
4d6de7500e
commit
7a37cb6f0b
src/com/maddyhome/idea/vim
@ -35,6 +35,7 @@ import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.inBlockSubMode
|
||||
import com.maddyhome.idea.vim.helper.inSelectMode
|
||||
import com.maddyhome.idea.vim.helper.inVisualMode
|
||||
import com.maddyhome.idea.vim.helper.mode
|
||||
import com.maddyhome.idea.vim.helper.subMode
|
||||
import com.maddyhome.idea.vim.helper.vimForEachCaret
|
||||
import com.maddyhome.idea.vim.helper.vimKeepingVisualOperatorAction
|
||||
@ -46,6 +47,7 @@ import com.maddyhome.idea.vim.helper.vimSelectionStartClear
|
||||
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
|
||||
import com.maddyhome.idea.vim.listener.VimListenerManager
|
||||
import com.maddyhome.idea.vim.option.OptionsManager
|
||||
import com.maddyhome.idea.vim.option.SelectModeOptionData
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
@ -128,9 +130,9 @@ class VisualMotionGroup {
|
||||
val selectMode = OptionsManager.selectmode
|
||||
when {
|
||||
editor.isOneLineMode -> enterSelectMode(editor, autodetectedMode)
|
||||
selectionSource == VimListenerManager.SelectionSource.MOUSE && "mouse" in selectMode -> enterSelectMode(editor, autodetectedMode)
|
||||
project != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null && "template" in selectMode -> enterSelectMode(editor, autodetectedMode)
|
||||
selectionSource == VimListenerManager.SelectionSource.OTHER && "refactoring" in selectMode -> enterSelectMode(editor, autodetectedMode)
|
||||
selectionSource == VimListenerManager.SelectionSource.MOUSE && SelectModeOptionData.mouse in selectMode -> enterSelectMode(editor, autodetectedMode)
|
||||
project != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null && SelectModeOptionData.template in selectMode -> enterSelectMode(editor, autodetectedMode)
|
||||
selectionSource == VimListenerManager.SelectionSource.OTHER && SelectModeOptionData.refactoring in selectMode -> enterSelectMode(editor, autodetectedMode)
|
||||
else -> enterVisualMode(editor, autodetectedMode)
|
||||
}
|
||||
KeyHandler.getInstance().reset(editor)
|
||||
@ -140,7 +142,7 @@ class VisualMotionGroup {
|
||||
exitSelectModeAndResetKeyHandler(editor, true)
|
||||
|
||||
val project = editor.project
|
||||
if (project != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null || modeBeforeEnteringNonVimVisual == CommandState.Mode.INSERT) {
|
||||
if ((project != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null || modeBeforeEnteringNonVimVisual == CommandState.Mode.INSERT) && editor.mode == CommandState.Mode.COMMAND) {
|
||||
VimPlugin.getChange().insertBeforeCursor(editor, EditorDataContext(editor))
|
||||
}
|
||||
KeyHandler.getInstance().reset(editor)
|
||||
|
@ -36,8 +36,10 @@ import com.intellij.openapi.project.Project
|
||||
import com.maddyhome.idea.vim.EventFacade
|
||||
import com.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.group.visual.moveCaretOneCharLeftFromSelectionEnd
|
||||
import com.maddyhome.idea.vim.helper.EditorDataContext
|
||||
import com.maddyhome.idea.vim.helper.mode
|
||||
import java.beans.PropertyChangeEvent
|
||||
import java.beans.PropertyChangeListener
|
||||
|
||||
@ -99,8 +101,10 @@ object IdeaSpecifics {
|
||||
if (!editor.selectionModel.hasSelection()) {
|
||||
// Enable insert mode if there is no selection in template
|
||||
// Template with selection is handled by [com.maddyhome.idea.vim.group.visual.VisualMotionGroup.controlNonVimSelectionChange]
|
||||
VimPlugin.getChange().insertBeforeCursor(editor, EditorDataContext(editor))
|
||||
KeyHandler.getInstance().reset(editor)
|
||||
if (editor.mode == CommandState.Mode.COMMAND) {
|
||||
VimPlugin.getChange().insertBeforeCursor(editor, EditorDataContext(editor))
|
||||
KeyHandler.getInstance().reset(editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user