diff --git a/src/main/java/com/maddyhome/idea/vim/extension/argtextobj/VimArgTextObjExtension.java b/src/main/java/com/maddyhome/idea/vim/extension/argtextobj/VimArgTextObjExtension.java index 15a2b5661..e22a26b17 100644 --- a/src/main/java/com/maddyhome/idea/vim/extension/argtextobj/VimArgTextObjExtension.java +++ b/src/main/java/com/maddyhome/idea/vim/extension/argtextobj/VimArgTextObjExtension.java @@ -9,6 +9,7 @@ package com.maddyhome.idea.vim.extension.argtextobj; import com.intellij.openapi.editor.Document; +import com.maddyhome.idea.vim.KeyHandler; import com.maddyhome.idea.vim.VimPlugin; import com.maddyhome.idea.vim.api.*; 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.newapi.IjVimCaret; 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.vimscript.model.datatypes.VimString; import org.jetbrains.annotations.Nls; @@ -244,19 +245,18 @@ public class VimArgTextObjExtension implements VimExtension { @Override public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) { - - IjVimEditor vimEditor = (IjVimEditor) editor; - @NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(vimEditor); - int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); + @NotNull KeyHandler keyHandler = KeyHandler.getInstance(); + @NotNull KeyHandlerState keyHandlerState = KeyHandler.getInstance().getKeyHandlerState(); + int count = Math.max(1, keyHandlerState.getCommandBuilder().getCount()); final ArgumentTextObjectHandler textObjectHandler = new ArgumentTextObjectHandler(isInner); //noinspection DuplicatedCode - if (!vimStateMachine.isOperatorPending(editor.getMode())) { + if (!keyHandler.isOperatorPending(editor.getMode(), keyHandlerState)) { editor.nativeCarets().forEach((VimCaret caret) -> { final TextRange range = textObjectHandler.getRange(editor, caret, context, count, 0); if (range != null) { 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); } else { InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret)caret).getCaret(), range.getStartOffset()); @@ -265,7 +265,7 @@ public class VimArgTextObjExtension implements VimExtension { } }); } 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)))); } } diff --git a/src/main/java/com/maddyhome/idea/vim/extension/commentary/CommentaryExtension.kt b/src/main/java/com/maddyhome/idea/vim/extension/commentary/CommentaryExtension.kt index 36c44cebf..5bc972973 100644 --- a/src/main/java/com/maddyhome/idea/vim/extension/commentary/CommentaryExtension.kt +++ b/src/main/java/com/maddyhome/idea/vim/extension/commentary/CommentaryExtension.kt @@ -18,6 +18,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiWhiteSpace 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.ImmutableVimCaret import com.maddyhome.idea.vim.api.VimEditor @@ -183,10 +184,10 @@ internal class CommentaryExtension : VimExtension { override val isRepeatable = true 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)) - commandState.commandBuilder.completeCommandPart(Argument(command)) + + val keyState = KeyHandler.getInstance().keyHandlerState + keyState.commandBuilder.completeCommandPart(Argument(command)) } } diff --git a/src/main/java/com/maddyhome/idea/vim/extension/matchit/Matchit.kt b/src/main/java/com/maddyhome/idea/vim/extension/matchit/Matchit.kt index 260ae49c8..35568d140 100644 --- a/src/main/java/com/maddyhome/idea/vim/extension/matchit/Matchit.kt +++ b/src/main/java/com/maddyhome/idea/vim/extension/matchit/Matchit.kt @@ -14,6 +14,7 @@ import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiComment import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil +import com.maddyhome.idea.vim.KeyHandler import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.ImmutableVimCaret @@ -91,22 +92,23 @@ internal class Matchit : VimExtension { private class MatchitHandler(private val reverse: Boolean) : ExtensionHandler { override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) { - val commandState = editor.vimStateMachine - val count = commandState.commandBuilder.count + val keyHandler = KeyHandler.getInstance() + val keyState = keyHandler.keyHandlerState + val count = keyState.commandBuilder.count // 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 // 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) { val matchitAction = MatchitAction() matchitAction.reverse = reverse matchitAction.isInOpPending = true - commandState.commandBuilder.completeCommandPart( + keyState.commandBuilder.completeCommandPart( Argument( Command( count, diff --git a/src/main/java/com/maddyhome/idea/vim/extension/textobjentire/VimTextObjEntireExtension.java b/src/main/java/com/maddyhome/idea/vim/extension/textobjentire/VimTextObjEntireExtension.java index 5d00af893..fea50a6f4 100644 --- a/src/main/java/com/maddyhome/idea/vim/extension/textobjentire/VimTextObjEntireExtension.java +++ b/src/main/java/com/maddyhome/idea/vim/extension/textobjentire/VimTextObjEntireExtension.java @@ -9,6 +9,7 @@ package com.maddyhome.idea.vim.extension.textobjentire; 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.ImmutableVimCaret; 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.newapi.IjVimCaret; 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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -133,17 +134,18 @@ public class VimTextObjEntireExtension implements VimExtension { @Override public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) { - @NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(editor); - int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); + @NotNull KeyHandler keyHandler = KeyHandler.getInstance(); + @NotNull KeyHandlerState keyHandlerState = KeyHandler.getInstance().getKeyHandlerState(); + int count = Math.max(1, keyHandlerState.getCommandBuilder().getCount()); final EntireTextObjectHandler textObjectHandler = new EntireTextObjectHandler(ignoreLeadingAndTrailing); //noinspection DuplicatedCode - if (!vimStateMachine.isOperatorPending(editor.getMode())) { + if (!keyHandler.isOperatorPending(editor.getMode(), keyHandlerState)) { ((IjVimEditor) editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> { final TextRange range = textObjectHandler.getRange(editor, new IjVimCaret(caret), context, count, 0); if (range != null) { 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); } else { InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset()); @@ -153,7 +155,7 @@ public class VimTextObjEntireExtension implements VimExtension { }); } 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)))); } diff --git a/src/main/java/com/maddyhome/idea/vim/extension/textobjindent/VimIndentObject.java b/src/main/java/com/maddyhome/idea/vim/extension/textobjindent/VimIndentObject.java index 5cd18c08f..bbbda1210 100644 --- a/src/main/java/com/maddyhome/idea/vim/extension/textobjindent/VimIndentObject.java +++ b/src/main/java/com/maddyhome/idea/vim/extension/textobjindent/VimIndentObject.java @@ -9,6 +9,7 @@ package com.maddyhome.idea.vim.extension.textobjindent; 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.ImmutableVimCaret; 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.newapi.IjVimCaret; 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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -263,17 +264,18 @@ public class VimIndentObject implements VimExtension { @Override public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) { IjVimEditor vimEditor = (IjVimEditor)editor; - @NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(vimEditor); - int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); + @NotNull KeyHandler keyHandler = KeyHandler.getInstance(); + @NotNull KeyHandlerState keyHandlerState = KeyHandler.getInstance().getKeyHandlerState(); + int count = Math.max(1, keyHandlerState.getCommandBuilder().getCount()); 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) -> { final TextRange range = textObjectHandler.getRange(vimEditor, new IjVimCaret(caret), context, count, 0); if (range != null) { 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); } else { InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset()); @@ -283,7 +285,7 @@ public class VimIndentObject implements VimExtension { }); } 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)))); } diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ShowCmd.kt b/src/main/java/com/maddyhome/idea/vim/ui/ShowCmd.kt index 37c145863..32cd2a184 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ShowCmd.kt +++ b/src/main/java/com/maddyhome/idea/vim/ui/ShowCmd.kt @@ -19,6 +19,7 @@ import com.intellij.openapi.wm.StatusBarWidgetFactory import com.intellij.openapi.wm.WindowManager import com.intellij.openapi.wm.impl.status.EditorBasedWidget import com.intellij.util.Consumer +import com.maddyhome.idea.vim.KeyHandler import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.globalOptions @@ -61,8 +62,8 @@ internal object ShowCmd { fun getFullText(editor: Editor?): String { if (!injector.globalOptions().showcmd || editor == null || editor.isDisposed) return "" - val editorState = editor.vim.vimStateMachine - return EngineStringHelper.toPrintableCharacters(editorState.commandBuilder.keys + editorState.mappingState.keys) + val keyState = KeyHandler.getInstance().keyHandlerState + return EngineStringHelper.toPrintableCharacters(keyState.commandBuilder.keys + keyState.mappingState.keys) } } diff --git a/src/test/java/org/jetbrains/plugins/ideavim/action/CopyActionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/action/CopyActionTest.kt index 33cf28aa4..6622e6a80 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/action/CopyActionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/action/CopyActionTest.kt @@ -8,10 +8,9 @@ package org.jetbrains.plugins.ideavim.action import com.intellij.idea.TestFor +import com.maddyhome.idea.vim.KeyHandler import com.maddyhome.idea.vim.VimPlugin 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 org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.TestWithoutNeovim @@ -147,7 +146,7 @@ class CopyActionTest : VimTestCase() { """.trimIndent(), ) - assertTrue(fixture.editor.vim.vimStateMachine.commandBuilder.isEmpty) + assertTrue(KeyHandler.getInstance().keyHandlerState.commandBuilder.isEmpty) } @Test diff --git a/src/test/java/org/jetbrains/plugins/ideavim/action/MotionActionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/action/MotionActionTest.kt index f42f31100..d166e8ec8 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/action/MotionActionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/action/MotionActionTest.kt @@ -7,6 +7,7 @@ */ package org.jetbrains.plugins.ideavim.action +import com.maddyhome.idea.vim.KeyHandler import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.helper.vimStateMachine @@ -74,7 +75,7 @@ class MotionActionTest : VimTestCase() { assertPluginError(false) val vimCommandState = fixture.editor.vimStateMachine kotlin.test.assertNotNull(vimCommandState) - assertEmpty(vimCommandState.commandBuilder.keys.toList()) + assertEmpty(KeyHandler.getInstance().keyHandlerState.commandBuilder.keys.toList()) } // |h| |l| diff --git a/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/RandomActionsPropertyTest.kt b/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/RandomActionsPropertyTest.kt index 5f9fc8f36..5d5673e97 100644 --- a/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/RandomActionsPropertyTest.kt +++ b/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/RandomActionsPropertyTest.kt @@ -11,10 +11,9 @@ package org.jetbrains.plugins.ideavim.propertybased import com.intellij.ide.IdeEventQueue import com.intellij.openapi.editor.Editor import com.intellij.testFramework.PlatformTestUtil +import com.maddyhome.idea.vim.KeyHandler 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.newapi.vim import org.jetbrains.jetCheck.Generator import org.jetbrains.jetCheck.ImperativeCommand import org.jetbrains.jetCheck.PropertyChecker @@ -88,7 +87,7 @@ class RandomActionsPropertyTest : VimPropertyTestBase() { private class AvailableActions(private val editor: Editor) : ImperativeCommand { 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 keyGenerator = Generator.integers(0, possibleKeys.lastIndex) diff --git a/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/VimPropertyTestBase.kt b/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/VimPropertyTestBase.kt index b5755150e..4511f7e78 100644 --- a/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/VimPropertyTestBase.kt +++ b/tests/property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased/VimPropertyTestBase.kt @@ -25,7 +25,8 @@ abstract class VimPropertyTestBase : VimTestCase() { } protected fun reset(editor: Editor) { - editor.vim.vimStateMachine.mappingState.resetMappingSequence() + val keyState = KeyHandler.getInstance().keyHandlerState + keyState.mappingState.resetMappingSequence() VimPlugin.getKey().resetKeyMappings() KeyHandler.getInstance().fullReset(editor.vim) diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt index 04efb9860..cba272e87 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt @@ -10,6 +10,7 @@ package com.maddyhome.idea.vim.action.ex import com.intellij.vim.annotations.CommandOrMotion 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.ImmutableVimCaret import com.maddyhome.idea.vim.api.VimEditor @@ -72,7 +73,8 @@ public class ProcessExCommandEntryAction : MotionActionHandler.SingleExecution() logger.debug("processing command") 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) } catch (e: ExException) { injector.messages.showStatusBarMessage(null, e.message) diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt index da82ac52c..af624e378 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt @@ -27,13 +27,6 @@ import javax.swing.KeyStroke * Used to maintain state before and while entering a Vim command (operator, motion, text object, etc.) */ 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 isDotRepeatInProgress: Boolean = false override var isRegisterPending: Boolean = false diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/state/VimStateMachine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/state/VimStateMachine.kt index 4a430ccf0..a4cedcc9d 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/state/VimStateMachine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/state/VimStateMachine.kt @@ -12,11 +12,8 @@ import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.globalOptions import com.maddyhome.idea.vim.api.injector 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.MappingState 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.state.mode.Mode 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.) */ 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 var isDotRepeatInProgress: Boolean public var isRegisterPending: Boolean diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/services/VimVariableServiceBase.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/services/VimVariableServiceBase.kt index b5c059825..b1381f345 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/services/VimVariableServiceBase.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/services/VimVariableServiceBase.kt @@ -8,6 +8,7 @@ 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.Key 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? { return when (name) { "count" -> { - val count = VimStateMachine.getInstance(editor).commandBuilder.count + val count = KeyHandler.getInstance().keyHandlerState.commandBuilder.count VimInt(count) } "count1" -> { - val count1 = VimStateMachine.getInstance(editor).commandBuilder.count.coerceAtLeast(1) + val count1 = KeyHandler.getInstance().keyHandlerState.commandBuilder.count.coerceAtLeast(1) VimInt(count1) } "searchforward" -> {