diff --git a/src/com/maddyhome/idea/vim/KeyHandler.java b/src/com/maddyhome/idea/vim/KeyHandler.java index 258ff17a19..7faae9b3ed 100644 --- a/src/com/maddyhome/idea/vim/KeyHandler.java +++ b/src/com/maddyhome/idea/vim/KeyHandler.java @@ -212,13 +212,15 @@ public void handleKey(@NotNull Editor editor, handleKeyRecursionCount++; try { + if (isEditorReset(key, editorState)) { + handleEditorReset(editor, key, context, editorState); + } + if (!allowKeyMappings || !handleKeyMapping(editor, key, context)) { if (isCommandCountKey(chKey, editorState)) { commandBuilder.addCountCharacter(key); } else if (isDeleteCommandCountKey(key, editorState)) { commandBuilder.deleteCountCharacter(); - } else if (isEditorReset(key, editorState)) { - handleEditorReset(editor, key, context, editorState); } // If we got this far the user is entering a command or supplying an argument to an entered command. // First let's check to see if we are at the point of expecting a single character argument to a command. @@ -564,7 +566,7 @@ private boolean isCommandCountKey(char chKey, @NotNull CommandState editorState) // Make sure to avoid handling '0' as the start of a count. final CommandBuilder commandBuilder = editorState.getCommandBuilder(); return ((editorState.getMode() == CommandState.Mode.COMMAND - &&editorState.getSubMode()!=CommandState.SubMode.REGISTER_PENDING) + &&editorState.getSubMode()!=CommandState.SubMode.REGISTER_PENDING) || editorState.getMode() == CommandState.Mode.VISUAL) && commandBuilder.isExpectingCount() && Character.isDigit(chKey) && (commandBuilder.getCount() > 0 || chKey != '0'); } diff --git a/test/org/jetbrains/plugins/ideavim/action/ResetModeActionTest.kt b/test/org/jetbrains/plugins/ideavim/action/ResetModeActionTest.kt index 06b3b670b8..3fed7f60e2 100644 --- a/test/org/jetbrains/plugins/ideavim/action/ResetModeActionTest.kt +++ b/test/org/jetbrains/plugins/ideavim/action/ResetModeActionTest.kt @@ -63,4 +63,12 @@ class ResetModeActionTest : VimTestCase() { doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection()) } + + fun `test reset from operator-pending mode with delete`() { + val keys = StringHelper.parseKeys("ddw") + val before = "A Discovery" + val after = "Discovery" + doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) + TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection()) + } }