1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-22 01:34:04 +02:00

Remove deprecated code from VimStateMachine

This commit is contained in:
filipp 2024-06-28 15:11:47 +03:00
parent 453cca3b0c
commit e67c7b23ff
14 changed files with 52 additions and 58 deletions
src
main/java/com/maddyhome/idea/vim
test/java/org/jetbrains/plugins/ideavim/action
tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased
vim-engine/src/main/kotlin/com/maddyhome/idea/vim

View File

@ -9,6 +9,7 @@
package com.maddyhome.idea.vim.extension.argtextobj; package com.maddyhome.idea.vim.extension.argtextobj;
import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Document;
import com.maddyhome.idea.vim.KeyHandler;
import com.maddyhome.idea.vim.VimPlugin; import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.api.*; import com.maddyhome.idea.vim.api.*;
import com.maddyhome.idea.vim.command.*; import com.maddyhome.idea.vim.command.*;
@ -23,7 +24,7 @@ import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor;
import com.maddyhome.idea.vim.listener.VimListenerSuppressor; import com.maddyhome.idea.vim.listener.VimListenerSuppressor;
import com.maddyhome.idea.vim.newapi.IjVimCaret; import com.maddyhome.idea.vim.newapi.IjVimCaret;
import com.maddyhome.idea.vim.newapi.IjVimEditor; import com.maddyhome.idea.vim.newapi.IjVimEditor;
import com.maddyhome.idea.vim.state.VimStateMachine; import com.maddyhome.idea.vim.state.KeyHandlerState;
import com.maddyhome.idea.vim.state.mode.Mode; import com.maddyhome.idea.vim.state.mode.Mode;
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString; import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.Nls;
@ -244,19 +245,18 @@ public class VimArgTextObjExtension implements VimExtension {
@Override @Override
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) { public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) {
@NotNull KeyHandler keyHandler = KeyHandler.getInstance();
IjVimEditor vimEditor = (IjVimEditor) editor; @NotNull KeyHandlerState keyHandlerState = KeyHandler.getInstance().getKeyHandlerState();
@NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(vimEditor); int count = Math.max(1, keyHandlerState.getCommandBuilder().getCount());
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final ArgumentTextObjectHandler textObjectHandler = new ArgumentTextObjectHandler(isInner); final ArgumentTextObjectHandler textObjectHandler = new ArgumentTextObjectHandler(isInner);
//noinspection DuplicatedCode //noinspection DuplicatedCode
if (!vimStateMachine.isOperatorPending(editor.getMode())) { if (!keyHandler.isOperatorPending(editor.getMode(), keyHandlerState)) {
editor.nativeCarets().forEach((VimCaret caret) -> { editor.nativeCarets().forEach((VimCaret caret) -> {
final TextRange range = textObjectHandler.getRange(editor, caret, context, count, 0); final TextRange range = textObjectHandler.getRange(editor, caret, context, count, 0);
if (range != null) { if (range != null) {
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) { try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
if (vimStateMachine.getMode() instanceof Mode.VISUAL) { if (editor.getMode() instanceof Mode.VISUAL) {
com.maddyhome.idea.vim.group.visual.EngineVisualGroupKt.vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true); com.maddyhome.idea.vim.group.visual.EngineVisualGroupKt.vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
} else { } else {
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret)caret).getCaret(), range.getStartOffset()); InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret)caret).getCaret(), range.getStartOffset());
@ -265,7 +265,7 @@ public class VimArgTextObjExtension implements VimExtension {
} }
}); });
} else { } else {
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count, keyHandlerState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags.class)))); textObjectHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags.class))));
} }
} }

View File

@ -18,6 +18,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
import com.intellij.psi.PsiWhiteSpace import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTreeUtil
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.ImmutableVimCaret import com.maddyhome.idea.vim.api.ImmutableVimCaret
import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimEditor
@ -183,10 +184,10 @@ internal class CommentaryExtension : VimExtension {
override val isRepeatable = true override val isRepeatable = true
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) { override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
val commandState = editor.vimStateMachine
val command = Command(operatorArguments.count1, CommentaryTextObjectMotionHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags::class.java)) val command = Command(operatorArguments.count1, CommentaryTextObjectMotionHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags::class.java))
commandState.commandBuilder.completeCommandPart(Argument(command))
val keyState = KeyHandler.getInstance().keyHandlerState
keyState.commandBuilder.completeCommandPart(Argument(command))
} }
} }

View File

@ -14,6 +14,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiComment import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTreeUtil
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.ImmutableVimCaret import com.maddyhome.idea.vim.api.ImmutableVimCaret
@ -91,22 +92,23 @@ internal class Matchit : VimExtension {
private class MatchitHandler(private val reverse: Boolean) : ExtensionHandler { private class MatchitHandler(private val reverse: Boolean) : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) { override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
val commandState = editor.vimStateMachine val keyHandler = KeyHandler.getInstance()
val count = commandState.commandBuilder.count val keyState = keyHandler.keyHandlerState
val count = keyState.commandBuilder.count
// Reset the command count so it doesn't transfer onto subsequent commands. // Reset the command count so it doesn't transfer onto subsequent commands.
editor.vimStateMachine.commandBuilder.resetCount() keyState.commandBuilder.resetCount()
// Normally we want to jump to the start of the matching pair. But when moving forward in operator // Normally we want to jump to the start of the matching pair. But when moving forward in operator
// pending mode, we want to include the entire match. isInOpPending makes that distinction. // pending mode, we want to include the entire match. isInOpPending makes that distinction.
val isInOpPending = commandState.isOperatorPending(editor.mode) val isInOpPending = keyHandler.isOperatorPending(editor.mode, keyState)
if (isInOpPending) { if (isInOpPending) {
val matchitAction = MatchitAction() val matchitAction = MatchitAction()
matchitAction.reverse = reverse matchitAction.reverse = reverse
matchitAction.isInOpPending = true matchitAction.isInOpPending = true
commandState.commandBuilder.completeCommandPart( keyState.commandBuilder.completeCommandPart(
Argument( Argument(
Command( Command(
count, count,

View File

@ -9,6 +9,7 @@
package com.maddyhome.idea.vim.extension.textobjentire; package com.maddyhome.idea.vim.extension.textobjentire;
import com.intellij.openapi.editor.Caret; import com.intellij.openapi.editor.Caret;
import com.maddyhome.idea.vim.KeyHandler;
import com.maddyhome.idea.vim.api.ExecutionContext; import com.maddyhome.idea.vim.api.ExecutionContext;
import com.maddyhome.idea.vim.api.ImmutableVimCaret; import com.maddyhome.idea.vim.api.ImmutableVimCaret;
import com.maddyhome.idea.vim.api.VimEditor; import com.maddyhome.idea.vim.api.VimEditor;
@ -23,7 +24,7 @@ import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor;
import com.maddyhome.idea.vim.listener.VimListenerSuppressor; import com.maddyhome.idea.vim.listener.VimListenerSuppressor;
import com.maddyhome.idea.vim.newapi.IjVimCaret; import com.maddyhome.idea.vim.newapi.IjVimCaret;
import com.maddyhome.idea.vim.newapi.IjVimEditor; import com.maddyhome.idea.vim.newapi.IjVimEditor;
import com.maddyhome.idea.vim.state.VimStateMachine; import com.maddyhome.idea.vim.state.KeyHandlerState;
import com.maddyhome.idea.vim.state.mode.Mode; import com.maddyhome.idea.vim.state.mode.Mode;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -133,17 +134,18 @@ public class VimTextObjEntireExtension implements VimExtension {
@Override @Override
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) { public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) {
@NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(editor); @NotNull KeyHandler keyHandler = KeyHandler.getInstance();
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); @NotNull KeyHandlerState keyHandlerState = KeyHandler.getInstance().getKeyHandlerState();
int count = Math.max(1, keyHandlerState.getCommandBuilder().getCount());
final EntireTextObjectHandler textObjectHandler = new EntireTextObjectHandler(ignoreLeadingAndTrailing); final EntireTextObjectHandler textObjectHandler = new EntireTextObjectHandler(ignoreLeadingAndTrailing);
//noinspection DuplicatedCode //noinspection DuplicatedCode
if (!vimStateMachine.isOperatorPending(editor.getMode())) { if (!keyHandler.isOperatorPending(editor.getMode(), keyHandlerState)) {
((IjVimEditor) editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> { ((IjVimEditor) editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> {
final TextRange range = textObjectHandler.getRange(editor, new IjVimCaret(caret), context, count, 0); final TextRange range = textObjectHandler.getRange(editor, new IjVimCaret(caret), context, count, 0);
if (range != null) { if (range != null) {
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) { try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
if (vimStateMachine.getMode() instanceof Mode.VISUAL) { if (editor.getMode() instanceof Mode.VISUAL) {
com.maddyhome.idea.vim.group.visual.EngineVisualGroupKt.vimSetSelection(new IjVimCaret(caret), range.getStartOffset(), range.getEndOffset() - 1, true); com.maddyhome.idea.vim.group.visual.EngineVisualGroupKt.vimSetSelection(new IjVimCaret(caret), range.getStartOffset(), range.getEndOffset() - 1, true);
} else { } else {
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset()); InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
@ -153,7 +155,7 @@ public class VimTextObjEntireExtension implements VimExtension {
}); });
} else { } else {
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count, keyHandlerState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION, textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class)))); EnumSet.noneOf(CommandFlags.class))));
} }

View File

@ -9,6 +9,7 @@
package com.maddyhome.idea.vim.extension.textobjindent; package com.maddyhome.idea.vim.extension.textobjindent;
import com.intellij.openapi.editor.Caret; import com.intellij.openapi.editor.Caret;
import com.maddyhome.idea.vim.KeyHandler;
import com.maddyhome.idea.vim.api.ExecutionContext; import com.maddyhome.idea.vim.api.ExecutionContext;
import com.maddyhome.idea.vim.api.ImmutableVimCaret; import com.maddyhome.idea.vim.api.ImmutableVimCaret;
import com.maddyhome.idea.vim.api.VimEditor; import com.maddyhome.idea.vim.api.VimEditor;
@ -24,7 +25,7 @@ import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor;
import com.maddyhome.idea.vim.listener.VimListenerSuppressor; import com.maddyhome.idea.vim.listener.VimListenerSuppressor;
import com.maddyhome.idea.vim.newapi.IjVimCaret; import com.maddyhome.idea.vim.newapi.IjVimCaret;
import com.maddyhome.idea.vim.newapi.IjVimEditor; import com.maddyhome.idea.vim.newapi.IjVimEditor;
import com.maddyhome.idea.vim.state.VimStateMachine; import com.maddyhome.idea.vim.state.KeyHandlerState;
import com.maddyhome.idea.vim.state.mode.Mode; import com.maddyhome.idea.vim.state.mode.Mode;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -263,17 +264,18 @@ public class VimIndentObject implements VimExtension {
@Override @Override
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) { public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) {
IjVimEditor vimEditor = (IjVimEditor)editor; IjVimEditor vimEditor = (IjVimEditor)editor;
@NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(vimEditor); @NotNull KeyHandler keyHandler = KeyHandler.getInstance();
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); @NotNull KeyHandlerState keyHandlerState = KeyHandler.getInstance().getKeyHandlerState();
int count = Math.max(1, keyHandlerState.getCommandBuilder().getCount());
final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow); final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow);
if (!vimStateMachine.isOperatorPending(editor.getMode())) { if (!keyHandler.isOperatorPending(editor.getMode(), keyHandlerState)) {
((IjVimEditor)editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> { ((IjVimEditor)editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> {
final TextRange range = textObjectHandler.getRange(vimEditor, new IjVimCaret(caret), context, count, 0); final TextRange range = textObjectHandler.getRange(vimEditor, new IjVimCaret(caret), context, count, 0);
if (range != null) { if (range != null) {
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) { try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
if (vimStateMachine.getMode() instanceof Mode.VISUAL) { if (editor.getMode() instanceof Mode.VISUAL) {
EngineVisualGroupKt.vimSetSelection(new IjVimCaret(caret), range.getStartOffset(), range.getEndOffset() - 1, true); EngineVisualGroupKt.vimSetSelection(new IjVimCaret(caret), range.getStartOffset(), range.getEndOffset() - 1, true);
} else { } else {
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset()); InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
@ -283,7 +285,7 @@ public class VimIndentObject implements VimExtension {
}); });
} else { } else {
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count, keyHandlerState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION, textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class)))); EnumSet.noneOf(CommandFlags.class))));
} }

View File

@ -19,6 +19,7 @@ import com.intellij.openapi.wm.StatusBarWidgetFactory
import com.intellij.openapi.wm.WindowManager import com.intellij.openapi.wm.WindowManager
import com.intellij.openapi.wm.impl.status.EditorBasedWidget import com.intellij.openapi.wm.impl.status.EditorBasedWidget
import com.intellij.util.Consumer import com.intellij.util.Consumer
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.globalOptions import com.maddyhome.idea.vim.api.globalOptions
@ -61,8 +62,8 @@ internal object ShowCmd {
fun getFullText(editor: Editor?): String { fun getFullText(editor: Editor?): String {
if (!injector.globalOptions().showcmd || editor == null || editor.isDisposed) return "" if (!injector.globalOptions().showcmd || editor == null || editor.isDisposed) return ""
val editorState = editor.vim.vimStateMachine val keyState = KeyHandler.getInstance().keyHandlerState
return EngineStringHelper.toPrintableCharacters(editorState.commandBuilder.keys + editorState.mappingState.keys) return EngineStringHelper.toPrintableCharacters(keyState.commandBuilder.keys + keyState.mappingState.keys)
} }
} }

View File

@ -8,10 +8,9 @@
package org.jetbrains.plugins.ideavim.action package org.jetbrains.plugins.ideavim.action
import com.intellij.idea.TestFor import com.intellij.idea.TestFor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.Mode import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -147,7 +146,7 @@ class CopyActionTest : VimTestCase() {
""".trimIndent(), """.trimIndent(),
) )
assertTrue(fixture.editor.vim.vimStateMachine.commandBuilder.isEmpty) assertTrue(KeyHandler.getInstance().keyHandlerState.commandBuilder.isEmpty)
} }
@Test @Test

View File

@ -7,6 +7,7 @@
*/ */
package org.jetbrains.plugins.ideavim.action package org.jetbrains.plugins.ideavim.action
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
@ -74,7 +75,7 @@ class MotionActionTest : VimTestCase() {
assertPluginError(false) assertPluginError(false)
val vimCommandState = fixture.editor.vimStateMachine val vimCommandState = fixture.editor.vimStateMachine
kotlin.test.assertNotNull(vimCommandState) kotlin.test.assertNotNull(vimCommandState)
assertEmpty(vimCommandState.commandBuilder.keys.toList()) assertEmpty(KeyHandler.getInstance().keyHandlerState.commandBuilder.keys.toList())
} }
// |h| |l| // |h| |l|

View File

@ -11,10 +11,9 @@ package org.jetbrains.plugins.ideavim.propertybased
import com.intellij.ide.IdeEventQueue import com.intellij.ide.IdeEventQueue
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.PlatformTestUtil
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.key.CommandNode import com.maddyhome.idea.vim.key.CommandNode
import com.maddyhome.idea.vim.newapi.vim
import org.jetbrains.jetCheck.Generator import org.jetbrains.jetCheck.Generator
import org.jetbrains.jetCheck.ImperativeCommand import org.jetbrains.jetCheck.ImperativeCommand
import org.jetbrains.jetCheck.PropertyChecker import org.jetbrains.jetCheck.PropertyChecker
@ -88,7 +87,7 @@ class RandomActionsPropertyTest : VimPropertyTestBase() {
private class AvailableActions(private val editor: Editor) : ImperativeCommand { private class AvailableActions(private val editor: Editor) : ImperativeCommand {
override fun performCommand(env: ImperativeCommand.Environment) { override fun performCommand(env: ImperativeCommand.Environment) {
val currentNode = editor.vim.vimStateMachine.commandBuilder.getCurrentTrie() val currentNode = KeyHandler.getInstance().keyHandlerState.commandBuilder.getCurrentTrie()
val possibleKeys = currentNode.keys.toList().sortedBy { injector.parser.toKeyNotation(it) } val possibleKeys = currentNode.keys.toList().sortedBy { injector.parser.toKeyNotation(it) }
val keyGenerator = Generator.integers(0, possibleKeys.lastIndex) val keyGenerator = Generator.integers(0, possibleKeys.lastIndex)

View File

@ -25,7 +25,8 @@ abstract class VimPropertyTestBase : VimTestCase() {
} }
protected fun reset(editor: Editor) { protected fun reset(editor: Editor) {
editor.vim.vimStateMachine.mappingState.resetMappingSequence() val keyState = KeyHandler.getInstance().keyHandlerState
keyState.mappingState.resetMappingSequence()
VimPlugin.getKey().resetKeyMappings() VimPlugin.getKey().resetKeyMappings()
KeyHandler.getInstance().fullReset(editor.vim) KeyHandler.getInstance().fullReset(editor.vim)

View File

@ -10,6 +10,7 @@ package com.maddyhome.idea.vim.action.ex
import com.intellij.vim.annotations.CommandOrMotion import com.intellij.vim.annotations.CommandOrMotion
import com.intellij.vim.annotations.Mode import com.intellij.vim.annotations.Mode
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.ImmutableVimCaret import com.maddyhome.idea.vim.api.ImmutableVimCaret
import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimEditor
@ -72,7 +73,8 @@ public class ProcessExCommandEntryAction : MotionActionHandler.SingleExecution()
logger.debug("processing command") logger.debug("processing command")
val text = argument.string val text = argument.string
val shouldSkipHistory = getInstance(editor).mappingState.isExecutingMap() || injector.macro.isExecutingMacro val keyState = KeyHandler.getInstance().keyHandlerState
val shouldSkipHistory = keyState.mappingState.isExecutingMap() || injector.macro.isExecutingMacro
injector.vimscriptExecutor.execute(text, editor, context, shouldSkipHistory, true, CommandLineVimLContext) injector.vimscriptExecutor.execute(text, editor, context, shouldSkipHistory, true, CommandLineVimLContext)
} catch (e: ExException) { } catch (e: ExException) {
injector.messages.showStatusBarMessage(null, e.message) injector.messages.showStatusBarMessage(null, e.message)

View File

@ -27,13 +27,6 @@ import javax.swing.KeyStroke
* Used to maintain state before and while entering a Vim command (operator, motion, text object, etc.) * Used to maintain state before and while entering a Vim command (operator, motion, text object, etc.)
*/ */
public class VimStateMachineImpl : VimStateMachine { public class VimStateMachineImpl : VimStateMachine {
@Deprecated("Please use KeyHandlerState instead")
override val commandBuilder: CommandBuilder = KeyHandler.getInstance().keyHandlerState.commandBuilder
@Deprecated("Please use KeyHandlerState instead")
override val mappingState: MappingState = KeyHandler.getInstance().keyHandlerState.mappingState
@Deprecated("Please use KeyHandlerState instead")
override val digraphSequence: DigraphSequence = KeyHandler.getInstance().keyHandlerState.digraphSequence
override var mode: Mode = Mode.NORMAL() override var mode: Mode = Mode.NORMAL()
override var isDotRepeatInProgress: Boolean = false override var isDotRepeatInProgress: Boolean = false
override var isRegisterPending: Boolean = false override var isRegisterPending: Boolean = false

View File

@ -12,11 +12,8 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.globalOptions import com.maddyhome.idea.vim.api.globalOptions
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.Command import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandBuilder
import com.maddyhome.idea.vim.command.CommandFlags import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.MappingState
import com.maddyhome.idea.vim.common.DigraphResult import com.maddyhome.idea.vim.common.DigraphResult
import com.maddyhome.idea.vim.common.DigraphSequence
import com.maddyhome.idea.vim.impl.state.VimStateMachineImpl import com.maddyhome.idea.vim.impl.state.VimStateMachineImpl
import com.maddyhome.idea.vim.state.mode.Mode import com.maddyhome.idea.vim.state.mode.Mode
import java.util.* import java.util.*
@ -26,13 +23,6 @@ import javax.swing.KeyStroke
* Used to maintain state before and while entering a Vim command (operator, motion, text object, etc.) * Used to maintain state before and while entering a Vim command (operator, motion, text object, etc.)
*/ */
public interface VimStateMachine { public interface VimStateMachine {
@Deprecated("Please use KeyHandlerState instead")
public val commandBuilder: CommandBuilder
@Deprecated("Please use KeyHandlerState instead")
public val mappingState: MappingState
@Deprecated("Please use KeyHandlerState instead")
public val digraphSequence: DigraphSequence
public val mode: Mode public val mode: Mode
public var isDotRepeatInProgress: Boolean public var isDotRepeatInProgress: Boolean
public var isRegisterPending: Boolean public var isRegisterPending: Boolean

View File

@ -8,6 +8,7 @@
package com.maddyhome.idea.vim.vimscript.services package com.maddyhome.idea.vim.vimscript.services
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.Key import com.maddyhome.idea.vim.api.Key
import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimEditor
@ -174,11 +175,11 @@ public abstract class VimVariableServiceBase : VariableService {
protected open fun getVimVariable(name: String, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext): VimDataType? { protected open fun getVimVariable(name: String, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext): VimDataType? {
return when (name) { return when (name) {
"count" -> { "count" -> {
val count = VimStateMachine.getInstance(editor).commandBuilder.count val count = KeyHandler.getInstance().keyHandlerState.commandBuilder.count
VimInt(count) VimInt(count)
} }
"count1" -> { "count1" -> {
val count1 = VimStateMachine.getInstance(editor).commandBuilder.count.coerceAtLeast(1) val count1 = KeyHandler.getInstance().keyHandlerState.commandBuilder.count.coerceAtLeast(1)
VimInt(count1) VimInt(count1)
} }
"searchforward" -> { "searchforward" -> {