1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-06-02 13:34:07 +02:00

[VIM-3051] Refactor the way we store modes in IdeaVim

Now we have a single variable with current mode instead of stack of modes.
This commit is contained in:
Alex Plate 2023-08-18 17:44:12 +03:00
parent 2e0ec73d77
commit e7a8b45c10
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
262 changed files with 2823 additions and 3337 deletions
src
main/java/com/maddyhome/idea/vim
test/java/org/jetbrains/plugins/ideavim
NeovimTesting.ktRegisterActionsTest.ktTestHelper.ktVimTestCase.kt
action
ChangeActionTest.ktChangeNumberActionTest.ktCopyActionTest.ktGuardedBlocksTest.ktMarkTest.ktMotionActionTest.ktMultipleCaretsTest.ktResetModeActionTest.kt
change
copy
motion

View File

@ -37,7 +37,6 @@ import com.maddyhome.idea.vim.helper.inNormalMode
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.isPrimaryEditor import com.maddyhome.idea.vim.helper.isPrimaryEditor
import com.maddyhome.idea.vim.helper.isTemplateActive import com.maddyhome.idea.vim.helper.isTemplateActive
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
import com.maddyhome.idea.vim.key.ShortcutOwner import com.maddyhome.idea.vim.key.ShortcutOwner
import com.maddyhome.idea.vim.key.ShortcutOwnerInfo import com.maddyhome.idea.vim.key.ShortcutOwnerInfo
@ -45,6 +44,7 @@ import com.maddyhome.idea.vim.listener.AceJumpService
import com.maddyhome.idea.vim.listener.AppCodeTemplates.appCodeTemplateCaptured import com.maddyhome.idea.vim.listener.AppCodeTemplates.appCodeTemplateCaptured
import com.maddyhome.idea.vim.newapi.globalIjOptions import com.maddyhome.idea.vim.newapi.globalIjOptions
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
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 java.awt.event.InputEvent import java.awt.event.InputEvent
import java.awt.event.KeyEvent import java.awt.event.KeyEvent

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.common.argumentCaptured import com.maddyhome.idea.vim.common.argumentCaptured
import com.maddyhome.idea.vim.group.MotionGroup import com.maddyhome.idea.vim.group.MotionGroup

View File

@ -63,7 +63,7 @@ internal class RepeatChangeAction : VimActionHandler.SingleExecution() {
mot.count = 0 mot.count = 0
} }
} }
state.setExecutingCommand(lastCommand) state.executingCommand = lastCommand
val arguments = operatorArguments.copy(count0 = lastCommand.rawCount) val arguments = operatorArguments.copy(count0 = lastCommand.rawCount)
injector.actionExecutor.executeVimAction(editor, lastCommand.action, context, arguments) injector.actionExecutor.executeVimAction(editor, lastCommand.action, context, arguments)
@ -76,7 +76,7 @@ internal class RepeatChangeAction : VimActionHandler.SingleExecution() {
state.isDotRepeatInProgress = false state.isDotRepeatInProgress = false
// Restore state // Restore state
if (save != null) state.setExecutingCommand(save) if (save != null) state.executingCommand = save
VimPlugin.getMotion().setLastFTCmd(lastFTCmd, lastFTChar) VimPlugin.getMotion().setLastFTCmd(lastFTCmd, lastFTChar)
if (lastHandler != null) Extension.lastExtensionHandler = lastHandler if (lastHandler != null) Extension.lastExtensionHandler = lastHandler
VimRepeater.repeatHandler = repeatHandler VimRepeater.repeatHandler = repeatHandler

View File

@ -11,6 +11,8 @@ package com.maddyhome.idea.vim.command
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.VimStateMachine
import com.maddyhome.idea.vim.state.mode.SelectionType
/** /**
* COMPATIBILITY-LAYER: Additional class * COMPATIBILITY-LAYER: Additional class
@ -22,7 +24,18 @@ public class CommandState(private val machine: VimStateMachine) {
get() = machine.isOperatorPending get() = machine.isOperatorPending
public val mode: CommandState.Mode public val mode: CommandState.Mode
get() = machine.mode.ij get() {
val myMode = machine.mode
return when (myMode) {
com.maddyhome.idea.vim.state.mode.Mode.CMD_LINE -> CommandState.Mode.CMD_LINE
com.maddyhome.idea.vim.state.mode.Mode.INSERT -> CommandState.Mode.INSERT
is com.maddyhome.idea.vim.state.mode.Mode.NORMAL -> CommandState.Mode.COMMAND
is com.maddyhome.idea.vim.state.mode.Mode.OP_PENDING -> CommandState.Mode.OP_PENDING
com.maddyhome.idea.vim.state.mode.Mode.REPLACE -> CommandState.Mode.REPLACE
is com.maddyhome.idea.vim.state.mode.Mode.SELECT -> CommandState.Mode.SELECT
is com.maddyhome.idea.vim.state.mode.Mode.VISUAL -> CommandState.Mode.VISUAL
}
}
public val commandBuilder: CommandBuilder public val commandBuilder: CommandBuilder
get() = machine.commandBuilder get() = machine.commandBuilder
@ -50,38 +63,10 @@ public class CommandState(private val machine: VimStateMachine) {
} }
} }
public val CommandState.SubMode.engine: VimStateMachine.SubMode internal val CommandState.SubMode.engine: SelectionType
get() = when (this) { get() = when (this) {
CommandState.SubMode.NONE -> VimStateMachine.SubMode.NONE CommandState.SubMode.NONE -> error("Unexpected value")
CommandState.SubMode.VISUAL_CHARACTER -> VimStateMachine.SubMode.VISUAL_CHARACTER CommandState.SubMode.VISUAL_CHARACTER -> SelectionType.CHARACTER_WISE
CommandState.SubMode.VISUAL_LINE -> VimStateMachine.SubMode.VISUAL_LINE CommandState.SubMode.VISUAL_LINE -> SelectionType.LINE_WISE
CommandState.SubMode.VISUAL_BLOCK -> VimStateMachine.SubMode.VISUAL_BLOCK CommandState.SubMode.VISUAL_BLOCK -> SelectionType.BLOCK_WISE
}
public val CommandState.Mode.engine: VimStateMachine.Mode
get() = when (this) {
CommandState.Mode.COMMAND -> VimStateMachine.Mode.COMMAND
CommandState.Mode.VISUAL -> VimStateMachine.Mode.VISUAL
CommandState.Mode.SELECT -> VimStateMachine.Mode.SELECT
CommandState.Mode.INSERT -> VimStateMachine.Mode.INSERT
CommandState.Mode.CMD_LINE -> VimStateMachine.Mode.CMD_LINE
CommandState.Mode.OP_PENDING -> VimStateMachine.Mode.OP_PENDING
CommandState.Mode.REPLACE -> VimStateMachine.Mode.REPLACE
CommandState.Mode.INSERT_NORMAL -> VimStateMachine.Mode.INSERT_NORMAL
CommandState.Mode.INSERT_VISUAL -> VimStateMachine.Mode.INSERT_VISUAL
CommandState.Mode.INSERT_SELECT -> VimStateMachine.Mode.INSERT_SELECT
}
public val VimStateMachine.Mode.ij: CommandState.Mode
get() = when (this) {
VimStateMachine.Mode.COMMAND -> CommandState.Mode.COMMAND
VimStateMachine.Mode.VISUAL -> CommandState.Mode.VISUAL
VimStateMachine.Mode.SELECT -> CommandState.Mode.SELECT
VimStateMachine.Mode.INSERT -> CommandState.Mode.INSERT
VimStateMachine.Mode.CMD_LINE -> CommandState.Mode.CMD_LINE
VimStateMachine.Mode.OP_PENDING -> CommandState.Mode.OP_PENDING
VimStateMachine.Mode.REPLACE -> CommandState.Mode.REPLACE
VimStateMachine.Mode.INSERT_NORMAL -> CommandState.Mode.INSERT_NORMAL
VimStateMachine.Mode.INSERT_VISUAL -> CommandState.Mode.INSERT_VISUAL
VimStateMachine.Mode.INSERT_SELECT -> CommandState.Mode.INSERT_SELECT
} }

View File

@ -17,7 +17,7 @@ import com.maddyhome.idea.vim.api.ImmutableVimCaret
import com.maddyhome.idea.vim.api.VimCaret import com.maddyhome.idea.vim.api.VimCaret
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.CommandAlias import com.maddyhome.idea.vim.common.CommandAlias
import com.maddyhome.idea.vim.common.CommandAliasHandler import com.maddyhome.idea.vim.common.CommandAliasHandler
import com.maddyhome.idea.vim.helper.CommandLineHelper import com.maddyhome.idea.vim.helper.CommandLineHelper

View File

@ -23,6 +23,8 @@ 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.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;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -244,7 +246,7 @@ public class VimArgTextObjExtension implements VimExtension {
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.getInstance(vimEditor); @NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(vimEditor);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final ArgumentTextObjectHandler textObjectHandler = new ArgumentTextObjectHandler(isInner); final ArgumentTextObjectHandler textObjectHandler = new ArgumentTextObjectHandler(isInner);
@ -254,7 +256,7 @@ public class VimArgTextObjExtension implements VimExtension {
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() == VimStateMachine.Mode.VISUAL) { if (vimStateMachine.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());

View File

@ -26,10 +26,10 @@ import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.command.TextObjectVisualType import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.common.CommandAliasHandler import com.maddyhome.idea.vim.common.CommandAliasHandler
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ranges.Ranges import com.maddyhome.idea.vim.ex.ranges.Ranges
@ -61,7 +61,7 @@ internal class CommentaryExtension : VimExtension {
resetCaret: Boolean, resetCaret: Boolean,
): Boolean { ): Boolean {
val mode = editor.vimStateMachine.mode val mode = editor.vimStateMachine.mode
if (mode !== VimStateMachine.Mode.VISUAL) { if (mode !is Mode.VISUAL) {
editor.ij.selectionModel.setSelection(range.startOffset, range.endOffset) editor.ij.selectionModel.setSelection(range.startOffset, range.endOffset)
} }
@ -88,13 +88,13 @@ internal class CommentaryExtension : VimExtension {
} }
private fun afterCommenting( private fun afterCommenting(
mode: VimStateMachine.Mode, mode: Mode,
editor: VimEditor, editor: VimEditor,
resetCaret: Boolean, resetCaret: Boolean,
range: TextRange, range: TextRange,
) { ) {
// Remove the selection, if we added it // Remove the selection, if we added it
if (mode !== VimStateMachine.Mode.VISUAL) { if (mode !is Mode.VISUAL) {
editor.removeSelection() editor.removeSelection()
} }
@ -159,9 +159,9 @@ internal class CommentaryExtension : VimExtension {
} }
// todo make it multicaret // todo make it multicaret
override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType): Boolean { override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType?): Boolean {
val range = injector.markService.getChangeMarks(editor.primaryCaret()) ?: return false val range = injector.markService.getChangeMarks(editor.primaryCaret()) ?: return false
return doCommentary(editor, context, range, selectionType, true) return doCommentary(editor, context, range, selectionType ?: SelectionType.CHARACTER_WISE, true)
} }
} }

View File

@ -23,8 +23,9 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.setChangeMarks import com.maddyhome.idea.vim.api.setChangeMarks
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.SelectionType.CHARACTER_WISE
import com.maddyhome.idea.vim.state.mode.selectionType
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.ExtensionHandler import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.extension.VimExtension import com.maddyhome.idea.vim.extension.VimExtension
@ -35,9 +36,9 @@ import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissin
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setRegister import com.maddyhome.idea.vim.extension.VimExtensionFacade.setRegister
import com.maddyhome.idea.vim.helper.fileSize import com.maddyhome.idea.vim.helper.fileSize
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.helper.moveToInlayAwareLogicalPosition import com.maddyhome.idea.vim.helper.moveToInlayAwareLogicalPosition
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.key.OperatorFunction import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.mark.Mark import com.maddyhome.idea.vim.mark.Mark
import com.maddyhome.idea.vim.mark.VimMarkConstants import com.maddyhome.idea.vim.mark.VimMarkConstants
@ -86,7 +87,7 @@ internal class VimExchangeExtension : VimExtension {
val EXCHANGE_KEY = Key<Exchange>("exchange") val EXCHANGE_KEY = Key<Exchange>("exchange")
// End mark has always greater of eq offset than start mark // End mark has always greater of eq offset than start mark
class Exchange(val type: VimStateMachine.SubMode, val start: Mark, val end: Mark, val text: String) { class Exchange(val type: SelectionType, val start: Mark, val end: Mark, val text: String) {
private var myHighlighter: RangeHighlighter? = null private var myHighlighter: RangeHighlighter? = null
fun setHighlighter(highlighter: RangeHighlighter) { fun setHighlighter(highlighter: RangeHighlighter) {
myHighlighter = highlighter myHighlighter = highlighter
@ -121,33 +122,32 @@ internal class VimExchangeExtension : VimExtension {
private class VExchangeHandler : ExtensionHandler { private class VExchangeHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) { override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
runWriteAction { runWriteAction {
val subMode = editor.subMode val mode = editor.mode
// Leave visual mode to create selection marks // Leave visual mode to create selection marks
executeNormalWithoutMapping(injector.parser.parseKeys("<Esc>"), editor.ij) executeNormalWithoutMapping(injector.parser.parseKeys("<Esc>"), editor.ij)
Operator(true).apply(editor, context, SelectionType.fromSubMode(subMode)) Operator(true).apply(editor, context, mode.selectionType ?: CHARACTER_WISE)
} }
} }
} }
private class Operator(private val isVisual: Boolean) : OperatorFunction { private class Operator(private val isVisual: Boolean) : OperatorFunction {
fun Editor.getMarkOffset(mark: Mark) = IjVimEditor(this).getOffset(mark.line, mark.col) fun Editor.getMarkOffset(mark: Mark) = IjVimEditor(this).getOffset(mark.line, mark.col)
fun VimStateMachine.SubMode.getString() = when (this) { fun SelectionType.getString() = when (this) {
VimStateMachine.SubMode.VISUAL_CHARACTER -> "v" SelectionType.CHARACTER_WISE -> "v"
VimStateMachine.SubMode.VISUAL_LINE -> "V" SelectionType.LINE_WISE -> "V"
VimStateMachine.SubMode.VISUAL_BLOCK -> "\\<C-V>" SelectionType.BLOCK_WISE -> "\\<C-V>"
else -> error("Invalid SubMode: $this")
} }
override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType): Boolean { override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType?): Boolean {
val ijEditor = editor.ij val ijEditor = editor.ij
fun highlightExchange(ex: Exchange): RangeHighlighter { fun highlightExchange(ex: Exchange): RangeHighlighter {
val attributes = ijEditor.colorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES) val attributes = ijEditor.colorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES)
val hlArea = when (ex.type) { val hlArea = when (ex.type) {
VimStateMachine.SubMode.VISUAL_LINE -> HighlighterTargetArea.LINES_IN_RANGE SelectionType.LINE_WISE -> HighlighterTargetArea.LINES_IN_RANGE
// TODO: handle other modes // TODO: handle other modes
else -> HighlighterTargetArea.EXACT_RANGE else -> HighlighterTargetArea.EXACT_RANGE
} }
val isVisualLine = ex.type == VimStateMachine.SubMode.VISUAL_LINE val isVisualLine = ex.type == SelectionType.LINE_WISE
val endAdj = if (!(isVisualLine) && (hlArea == HighlighterTargetArea.EXACT_RANGE || (isVisual))) 1 else 0 val endAdj = if (!(isVisualLine) && (hlArea == HighlighterTargetArea.EXACT_RANGE || (isVisual))) 1 else 0
return ijEditor.markupModel.addRangeHighlighter( return ijEditor.markupModel.addRangeHighlighter(
ijEditor.getMarkOffset(ex.start), ijEditor.getMarkOffset(ex.start),
@ -158,7 +158,7 @@ internal class VimExchangeExtension : VimExtension {
) )
} }
val currentExchange = getExchange(ijEditor, isVisual, selectionType) val currentExchange = getExchange(ijEditor, isVisual, selectionType ?: CHARACTER_WISE)
val exchange1 = ijEditor.getUserData(EXCHANGE_KEY) val exchange1 = ijEditor.getUserData(EXCHANGE_KEY)
if (exchange1 == null) { if (exchange1 == null) {
val highlighter = highlightExchange(currentExchange) val highlighter = highlightExchange(currentExchange)
@ -203,7 +203,7 @@ internal class VimExchangeExtension : VimExtension {
TextRange(editor.getMarkOffset(targetExchange.start), editor.getMarkOffset(targetExchange.end) + 1), TextRange(editor.getMarkOffset(targetExchange.start), editor.getMarkOffset(targetExchange.end) + 1),
) )
// do this instead of direct text manipulation to set change marks // do this instead of direct text manipulation to set change marks
setRegister('z', injector.parser.stringToKeys(sourceExchange.text), SelectionType.fromSubMode(sourceExchange.type)) setRegister('z', injector.parser.stringToKeys(sourceExchange.text), sourceExchange.type)
executeNormalWithoutMapping(injector.parser.stringToKeys("`[${targetExchange.type.getString()}`]\"zp"), editor) executeNormalWithoutMapping(injector.parser.stringToKeys("`[${targetExchange.type.getString()}`]\"zp"), editor)
} }
@ -269,7 +269,7 @@ internal class VimExchangeExtension : VimExtension {
x.line - y.line x.line - y.line
} }
return if (x.type == VimStateMachine.SubMode.VISUAL_BLOCK && y.type == VimStateMachine.SubMode.VISUAL_BLOCK) { return if (x.type == SelectionType.BLOCK_WISE && y.type == SelectionType.BLOCK_WISE) {
when { when {
intersects(x, y) -> { intersects(x, y) -> {
ExchangeCompareResult.OVERLAP ExchangeCompareResult.OVERLAP
@ -348,9 +348,9 @@ internal class VimExchangeExtension : VimExtension {
setRegister('+', plusRegText) setRegister('+', plusRegText)
return if (selectionStart.offset(editor.vim) <= selectionEnd.offset(editor.vim)) { return if (selectionStart.offset(editor.vim) <= selectionEnd.offset(editor.vim)) {
Exchange(selectionType.toSubMode(), selectionStart, selectionEnd, text) Exchange(selectionType, selectionStart, selectionEnd, text)
} else { } else {
Exchange(selectionType.toSubMode(), selectionEnd, selectionStart, text) Exchange(selectionType, selectionEnd, selectionStart, text)
} }
} }
} }

View File

@ -23,7 +23,6 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.options import com.maddyhome.idea.vim.api.options
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.ExtensionHandler import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.extension.VimExtension import com.maddyhome.idea.vim.extension.VimExtension
@ -42,6 +41,7 @@ import com.maddyhome.idea.vim.helper.userData
import com.maddyhome.idea.vim.newapi.IjVimEditor import com.maddyhome.idea.vim.newapi.IjVimEditor
import com.maddyhome.idea.vim.newapi.ij import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.SelectionType
import kotlin.math.max import kotlin.math.max
import kotlin.math.min import kotlin.math.min
@ -312,7 +312,7 @@ internal class VimMultipleCursorsExtension : VimExtension {
private fun enterVisualMode(editor: VimEditor) { private fun enterVisualMode(editor: VimEditor) {
// We need to reset the key handler to make sure we pick up the fact that we're in visual mode // We need to reset the key handler to make sure we pick up the fact that we're in visual mode
VimPlugin.getVisualMotion().enterVisualMode(editor, VimStateMachine.SubMode.VISUAL_CHARACTER) VimPlugin.getVisualMotion().enterVisualMode(editor, SelectionType.CHARACTER_WISE)
KeyHandler.getInstance().reset(editor) KeyHandler.getInstance().reset(editor)
} }

View File

@ -16,10 +16,12 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.getLineEndOffset import com.maddyhome.idea.vim.api.getLineEndOffset
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.SelectionType.CHARACTER_WISE
import com.maddyhome.idea.vim.command.isLine import com.maddyhome.idea.vim.state.mode.isLine
import com.maddyhome.idea.vim.state.mode.selectionType
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.ExtensionHandler import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.extension.VimExtension import com.maddyhome.idea.vim.extension.VimExtension
@ -29,8 +31,7 @@ import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissin
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction
import com.maddyhome.idea.vim.group.visual.VimSelection import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.helper.exitVisualMode import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.helper.mode import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.key.OperatorFunction import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.newapi.IjVimEditor import com.maddyhome.idea.vim.newapi.IjVimEditor
@ -56,7 +57,7 @@ internal class ReplaceWithRegister : VimExtension {
private class RwrVisual : ExtensionHandler { private class RwrVisual : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) { override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
val typeInEditor = SelectionType.fromSubMode(editor.subMode) val typeInEditor = editor.mode.selectionType ?: CHARACTER_WISE
editor.sortedCarets().forEach { caret -> editor.sortedCarets().forEach { caret ->
val selectionStart = caret.selectionStart val selectionStart = caret.selectionStart
val selectionEnd = caret.selectionEnd val selectionEnd = caret.selectionEnd
@ -103,7 +104,7 @@ internal class ReplaceWithRegister : VimExtension {
} }
private class Operator : OperatorFunction { private class Operator : OperatorFunction {
override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType): Boolean { override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType?): Boolean {
val ijEditor = (editor as IjVimEditor).editor val ijEditor = (editor as IjVimEditor).editor
val range = getRange(ijEditor) ?: return false val range = getRange(ijEditor) ?: return false
val visualSelection = PutData.VisualSelection( val visualSelection = PutData.VisualSelection(
@ -111,11 +112,11 @@ internal class ReplaceWithRegister : VimExtension {
editor.primaryCaret() to VimSelection.create( editor.primaryCaret() to VimSelection.create(
range.startOffset, range.startOffset,
range.endOffset - 1, range.endOffset - 1,
selectionType, selectionType ?: CHARACTER_WISE,
editor, editor,
), ),
), ),
selectionType, selectionType ?: CHARACTER_WISE,
) )
// todo multicaret // todo multicaret
doReplace(ijEditor, editor.primaryCaret(), visualSelection) doReplace(ijEditor, editor.primaryCaret(), visualSelection)
@ -124,8 +125,8 @@ internal class ReplaceWithRegister : VimExtension {
// todo make it work with multiple carets // todo make it work with multiple carets
private fun getRange(editor: Editor): TextRange? = when (editor.vim.mode) { private fun getRange(editor: Editor): TextRange? = when (editor.vim.mode) {
VimStateMachine.Mode.COMMAND -> injector.markService.getChangeMarks(editor.caretModel.primaryCaret.vim) is Mode.NORMAL -> injector.markService.getChangeMarks(editor.caretModel.primaryCaret.vim)
VimStateMachine.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) } is Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
else -> null else -> null
} }
} }
@ -173,7 +174,6 @@ internal class ReplaceWithRegister : VimExtension {
editor.vimStateMachine?.isOperatorPending ?: false, editor.vimStateMachine?.isOperatorPending ?: false,
0, 0,
editor.vim.mode, editor.vim.mode,
editor.vim.subMode,
), ),
saveToRegister = false saveToRegister = false
) )

View File

@ -18,9 +18,10 @@ import com.maddyhome.idea.vim.api.getLeadingCharacterOffset
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.setChangeMarks import com.maddyhome.idea.vim.api.setChangeMarks
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.selectionType
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.ExtensionHandler import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.extension.VimExtension import com.maddyhome.idea.vim.extension.VimExtension
@ -32,8 +33,7 @@ import com.maddyhome.idea.vim.extension.VimExtensionFacade.putExtensionHandlerMa
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setRegisterForCaret import com.maddyhome.idea.vim.extension.VimExtensionFacade.setRegisterForCaret
import com.maddyhome.idea.vim.helper.mode import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.key.OperatorFunction import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.newapi.ij import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
@ -122,7 +122,7 @@ internal class VimSurroundExtension : VimExtension {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) { override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
val selectionStart = editor.ij.caretModel.primaryCaret.selectionStart val selectionStart = editor.ij.caretModel.primaryCaret.selectionStart
// NB: Operator ignores SelectionType anyway // NB: Operator ignores SelectionType anyway
if (!Operator().apply(editor, context, SelectionType.fromSubMode(editor.subMode))) { if (!Operator().apply(editor, context, editor.mode.selectionType)) {
return return
} }
runWriteAction { runWriteAction {
@ -256,7 +256,7 @@ internal class VimSurroundExtension : VimExtension {
} }
private class Operator : OperatorFunction { private class Operator : OperatorFunction {
override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType): Boolean { override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType?): Boolean {
val ijEditor = editor.ij val ijEditor = editor.ij
val c = getChar(ijEditor) val c = getChar(ijEditor)
if (c.code == 0) return true if (c.code == 0) return true
@ -274,8 +274,8 @@ internal class VimSurroundExtension : VimExtension {
val editor = caret.editor val editor = caret.editor
val ijEditor = editor.ij val ijEditor = editor.ij
return when (ijEditor.vim.mode) { return when (ijEditor.vim.mode) {
VimStateMachine.Mode.COMMAND -> injector.markService.getChangeMarks(caret) is Mode.NORMAL -> injector.markService.getChangeMarks(caret)
VimStateMachine.Mode.VISUAL -> caret.run { TextRange(selectionStart, selectionEnd) } is Mode.VISUAL -> caret.run { TextRange(selectionStart, selectionEnd) }
else -> null else -> null
} }
} }

View File

@ -23,6 +23,8 @@ 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.mode.Mode;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -131,7 +133,7 @@ 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.getInstance(editor); @NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(editor);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final EntireTextObjectHandler textObjectHandler = new EntireTextObjectHandler(ignoreLeadingAndTrailing); final EntireTextObjectHandler textObjectHandler = new EntireTextObjectHandler(ignoreLeadingAndTrailing);
@ -141,7 +143,7 @@ public class VimTextObjEntireExtension implements VimExtension {
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() == VimStateMachine.Mode.VISUAL) { if (vimStateMachine.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());

View File

@ -24,6 +24,8 @@ 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.mode.Mode;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -260,7 +262,7 @@ 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.getInstance(vimEditor); @NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(vimEditor);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount()); int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow); final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow);
@ -270,7 +272,7 @@ public class VimIndentObject implements VimExtension {
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() == VimStateMachine.Mode.VISUAL) { if (vimStateMachine.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());

View File

@ -48,6 +48,8 @@ import com.maddyhome.idea.vim.newapi.IjEditorExecutionContext;
import com.maddyhome.idea.vim.newapi.IjEditorExecutionContextKt; import com.maddyhome.idea.vim.newapi.IjEditorExecutionContextKt;
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.mode.Mode;
import com.maddyhome.idea.vim.state.mode.SelectionType;
import com.maddyhome.idea.vim.vimscript.model.commands.SortOption; import com.maddyhome.idea.vim.vimscript.model.commands.SortOption;
import kotlin.Pair; import kotlin.Pair;
import kotlin.Unit; import kotlin.Unit;
@ -177,8 +179,8 @@ public class ChangeGroup extends VimChangeGroupBase {
final int lines = VimChangeGroupBase.Companion.getLinesCountInVisualBlock(editor, range); final int lines = VimChangeGroupBase.Companion.getLinesCountInVisualBlock(editor, range);
final BufferPosition startPosition = editor.offsetToBufferPosition(range.getStartOffset()); final BufferPosition startPosition = editor.offsetToBufferPosition(range.getStartOffset());
boolean visualBlockMode = operatorArguments.getMode() == VimStateMachine.Mode.VISUAL && boolean visualBlockMode =
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK; operatorArguments.getMode() instanceof Mode.VISUAL mode && mode.getSelectionType() == SelectionType.BLOCK_WISE;
for (VimCaret caret : editor.carets()) { for (VimCaret caret : editor.carets()) {
final int line = startPosition.getLine(); final int line = startPosition.getLine();
int column = startPosition.getColumn(); int column = startPosition.getColumn();

View File

@ -30,7 +30,8 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.ProjectScope; import com.intellij.psi.search.ProjectScope;
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.VimStateMachine; import com.maddyhome.idea.vim.state.mode.Mode;
import com.maddyhome.idea.vim.state.VimStateMachine;
import com.maddyhome.idea.vim.common.TextRange; import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.helper.EditorHelper; import com.maddyhome.idea.vim.helper.EditorHelper;
import com.maddyhome.idea.vim.helper.EditorHelperRt; import com.maddyhome.idea.vim.helper.EditorHelperRt;
@ -296,7 +297,7 @@ public class FileGroup extends VimFileBase {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
Document doc = editor.getDocument(); Document doc = editor.getDocument();
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() != VimStateMachine.Mode.VISUAL) { if (!(VimStateMachine.Companion.getInstance(new IjVimEditor(editor)).getMode() instanceof Mode.VISUAL)) {
LogicalPosition lp = editor.getCaretModel().getLogicalPosition(); LogicalPosition lp = editor.getCaretModel().getLogicalPosition();
int col = editor.getCaretModel().getOffset() - doc.getLineStartOffset(lp.line); int col = editor.getCaretModel().getOffset() - doc.getLineStartOffset(lp.line);
int endoff = doc.getLineEndOffset(lp.line); int endoff = doc.getLineEndOffset(lp.line);

View File

@ -46,8 +46,9 @@ import com.maddyhome.idea.vim.api.options
import com.maddyhome.idea.vim.api.visualLineToBufferLine import com.maddyhome.idea.vim.api.visualLineToBufferLine
import com.maddyhome.idea.vim.command.Argument import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.MotionType import com.maddyhome.idea.vim.command.MotionType
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.VimStateMachine
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ExOutputModel import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.handler.Motion import com.maddyhome.idea.vim.handler.Motion
@ -460,7 +461,7 @@ internal class MotionGroup : VimMotionGroupBase() {
val editor = fileEditor.editor val editor = fileEditor.editor
ExOutputModel.getInstance(editor).clear() ExOutputModel.getInstance(editor).clear()
editor.vim.let { vimEditor -> editor.vim.let { vimEditor ->
if (VimStateMachine.getInstance(vimEditor).mode === VimStateMachine.Mode.VISUAL) { if (VimStateMachine.getInstance(vimEditor).mode is Mode.VISUAL) {
vimEditor.exitVisualMode() vimEditor.exitVisualMode()
KeyHandler.getInstance().reset(vimEditor) KeyHandler.getInstance().reset(vimEditor)
} }

View File

@ -30,7 +30,8 @@ import com.maddyhome.idea.vim.api.VimEditor;
import com.maddyhome.idea.vim.api.VimInjectorKt; import com.maddyhome.idea.vim.api.VimInjectorKt;
import com.maddyhome.idea.vim.api.VimProcessGroupBase; import com.maddyhome.idea.vim.api.VimProcessGroupBase;
import com.maddyhome.idea.vim.command.Command; import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.VimStateMachine; import com.maddyhome.idea.vim.state.mode.Mode;
import com.maddyhome.idea.vim.state.VimStateMachine;
import com.maddyhome.idea.vim.ex.ExException; import com.maddyhome.idea.vim.ex.ExException;
import com.maddyhome.idea.vim.ex.InvalidCommandException; import com.maddyhome.idea.vim.ex.InvalidCommandException;
import com.maddyhome.idea.vim.helper.UiHelper; import com.maddyhome.idea.vim.helper.UiHelper;
@ -81,7 +82,8 @@ public class ProcessGroup extends VimProcessGroupBase {
if (editor.isOneLineMode()) return; if (editor.isOneLineMode()) return;
String initText = getRange(((IjVimEditor) editor).getEditor(), cmd); String initText = getRange(((IjVimEditor) editor).getEditor(), cmd);
VimStateMachine.getInstance(editor).pushModes(VimStateMachine.Mode.CMD_LINE, VimStateMachine.SubMode.NONE); injector.getMarkService().setVisualSelectionMarks(editor);
VimStateMachine.Companion.getInstance(editor).setMode(Mode.CMD_LINE.INSTANCE);
ExEntryPanel panel = ExEntryPanel.getInstance(); ExEntryPanel panel = ExEntryPanel.getInstance();
panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1); panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
} }
@ -99,7 +101,7 @@ public class ProcessGroup extends VimProcessGroupBase {
return true; return true;
} }
else { else {
VimStateMachine.getInstance(editor).popModes(); VimStateMachine.Companion.getInstance(editor).setMode(new Mode.NORMAL());
KeyHandler.getInstance().reset(editor); KeyHandler.getInstance().reset(editor);
return false; return false;
} }
@ -110,7 +112,7 @@ public class ProcessGroup extends VimProcessGroupBase {
panel.deactivate(true); panel.deactivate(true);
boolean res = true; boolean res = true;
try { try {
VimStateMachine.getInstance(editor).popModes(); VimStateMachine.Companion.getInstance(editor).setMode(new Mode.NORMAL());
logger.debug("processing command"); logger.debug("processing command");
@ -143,11 +145,11 @@ public class ProcessGroup extends VimProcessGroupBase {
// commands executed from map command / macro should not be added to history // commands executed from map command / macro should not be added to history
private boolean skipHistory(VimEditor editor) { private boolean skipHistory(VimEditor editor) {
return VimStateMachine.getInstance(editor).getMappingState().isExecutingMap() || injector.getMacro().isExecutingMacro(); return VimStateMachine.Companion.getInstance(editor).getMappingState().isExecutingMap() || injector.getMacro().isExecutingMacro();
} }
public void cancelExEntry(final @NotNull VimEditor editor, boolean resetCaret) { public void cancelExEntry(final @NotNull VimEditor editor, boolean resetCaret) {
VimStateMachine.getInstance(editor).popModes(); VimStateMachine.Companion.getInstance(editor).setMode(new Mode.NORMAL());
KeyHandler.getInstance().reset(editor); KeyHandler.getInstance().reset(editor);
ExEntryPanel panel = ExEntryPanel.getInstance(); ExEntryPanel panel = ExEntryPanel.getInstance();
panel.deactivate(true, resetCaret); panel.deactivate(true, resetCaret);
@ -156,14 +158,14 @@ public class ProcessGroup extends VimProcessGroupBase {
@Override @Override
public void startFilterCommand(@NotNull VimEditor editor, ExecutionContext context, @NotNull Command cmd) { public void startFilterCommand(@NotNull VimEditor editor, ExecutionContext context, @NotNull Command cmd) {
String initText = getRange(((IjVimEditor) editor).getEditor(), cmd) + "!"; String initText = getRange(((IjVimEditor) editor).getEditor(), cmd) + "!";
VimStateMachine.getInstance(editor).pushModes(VimStateMachine.Mode.CMD_LINE, VimStateMachine.SubMode.NONE); VimStateMachine.Companion.getInstance(editor).setMode(Mode.CMD_LINE.INSTANCE);
ExEntryPanel panel = ExEntryPanel.getInstance(); ExEntryPanel panel = ExEntryPanel.getInstance();
panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1); panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
} }
private @NotNull String getRange(Editor editor, @NotNull Command cmd) { private @NotNull String getRange(Editor editor, @NotNull Command cmd) {
String initText = ""; String initText = "";
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) { if (VimStateMachine.Companion.getInstance(new IjVimEditor(editor)).getMode() instanceof Mode.VISUAL) {
initText = "'<,'>"; initText = "'<,'>";
} }
else if (cmd.getRawCount() > 0) { else if (cmd.getRawCount() > 0) {

View File

@ -14,7 +14,7 @@ import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage; import com.intellij.openapi.components.Storage;
import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diagnostic.Logger;
import com.maddyhome.idea.vim.VimPlugin; import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.command.SelectionType; import com.maddyhome.idea.vim.state.mode.SelectionType;
import com.maddyhome.idea.vim.register.Register; import com.maddyhome.idea.vim.register.Register;
import com.maddyhome.idea.vim.register.VimRegisterGroupBase; import com.maddyhome.idea.vim.register.VimRegisterGroupBase;
import org.jdom.Element; import org.jdom.Element;
@ -50,7 +50,7 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
} }
final Element registerElement = new Element("register"); final Element registerElement = new Element("register");
registerElement.setAttribute("name", String.valueOf(key)); registerElement.setAttribute("name", String.valueOf(key));
registerElement.setAttribute("type", Integer.toString(register.getType().getValue())); registerElement.setAttribute("type", register.getType().name());
final String text = register.getText(); final String text = register.getText();
if (text != null) { if (text != null) {
logger.trace("Save register as 'text'"); logger.trace("Save register as 'text'");
@ -95,7 +95,25 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
final Register register; final Register register;
final Element textElement = registerElement.getChild("text"); final Element textElement = registerElement.getChild("text");
final String typeText = registerElement.getAttributeValue("type"); final String typeText = registerElement.getAttributeValue("type");
final SelectionType type = SelectionType.fromValue(Integer.parseInt(typeText)); SelectionType type;
try {
type = SelectionType.valueOf(typeText);
}
catch (IllegalArgumentException e) {
// This whole `if` keeps compatibility with the mode when SelectionType had numbers
if (Integer.toString(1 << 1).equals(typeText)) {
type = SelectionType.CHARACTER_WISE;
}
else if (Integer.toString(1 << 2).equals(typeText)) {
type = SelectionType.LINE_WISE;
}
else if (Integer.toString(1 << 3).equals(typeText)) {
type = SelectionType.BLOCK_WISE;
}
else {
type = SelectionType.CHARACTER_WISE;
}
}
if (textElement != null) { if (textElement != null) {
logger.trace("Register has 'text' element"); logger.trace("Register has 'text' element");
final String text = VimPlugin.getXML().getSafeXmlText(textElement); final String text = VimPlugin.getXML().getSafeXmlText(textElement);

View File

@ -27,11 +27,10 @@ import com.maddyhome.idea.vim.api.getLineEndOffset
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.api.setChangeMarks import com.maddyhome.idea.vim.api.setChangeMarks
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.isBlock
import com.maddyhome.idea.vim.command.isBlock import com.maddyhome.idea.vim.state.mode.isChar
import com.maddyhome.idea.vim.command.isChar import com.maddyhome.idea.vim.state.mode.isLine
import com.maddyhome.idea.vim.command.isLine
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.diagnostic.debug import com.maddyhome.idea.vim.diagnostic.debug
import com.maddyhome.idea.vim.helper.EditorHelper import com.maddyhome.idea.vim.helper.EditorHelper
@ -74,7 +73,7 @@ internal class PutGroup : VimPutBase() {
vimEditor: VimEditor, vimEditor: VimEditor,
vimContext: ExecutionContext, vimContext: ExecutionContext,
text: ProcessedTextData, text: ProcessedTextData,
subMode: VimStateMachine.SubMode, subMode: SelectionType,
data: PutData, data: PutData,
additionalData: Map<String, Any>, additionalData: Map<String, Any>,
) { ) {

View File

@ -15,22 +15,22 @@ 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.api.options import com.maddyhome.idea.vim.api.options
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.exitSelectMode import com.maddyhome.idea.vim.helper.exitSelectMode
import com.maddyhome.idea.vim.helper.exitVisualMode import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.helper.hasVisualSelection import com.maddyhome.idea.vim.helper.hasVisualSelection
import com.maddyhome.idea.vim.helper.inInsertMode import com.maddyhome.idea.vim.helper.inInsertMode
import com.maddyhome.idea.vim.helper.inNormalMode import com.maddyhome.idea.vim.helper.inNormalMode
import com.maddyhome.idea.vim.helper.inSelectMode
import com.maddyhome.idea.vim.helper.inVisualMode
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.isTemplateActive import com.maddyhome.idea.vim.helper.isTemplateActive
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.popAllModes
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.listener.VimListenerManager import com.maddyhome.idea.vim.listener.VimListenerManager
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.inNormalMode
import com.maddyhome.idea.vim.state.mode.inSelectMode
import com.maddyhome.idea.vim.state.mode.inVisualMode
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.vimscript.model.options.helpers.IdeaRefactorModeHelper import com.maddyhome.idea.vim.vimscript.model.options.helpers.IdeaRefactorModeHelper
import com.maddyhome.idea.vim.vimscript.model.options.helpers.isIdeaRefactorModeKeep import com.maddyhome.idea.vim.vimscript.model.options.helpers.isIdeaRefactorModeKeep
import com.maddyhome.idea.vim.vimscript.model.options.helpers.isIdeaRefactorModeSelect import com.maddyhome.idea.vim.vimscript.model.options.helpers.isIdeaRefactorModeSelect
@ -70,17 +70,17 @@ internal object IdeaSelectionControl {
return@singleTask return@singleTask
} }
logger.debug("Some carets have selection. State before adjustment: ${editor.vim.vimStateMachine.toSimpleString()}") logger.debug("Some carets have selection. State before adjustment: ${editor.vim.mode}")
editor.popAllModes() editor.vim.vimStateMachine.mode = Mode.NORMAL()
activateMode(editor, chooseSelectionMode(editor, selectionSource, true)) activateMode(editor, chooseSelectionMode(editor, selectionSource, true))
} else { } else {
logger.debug("None of carets have selection. State before adjustment: ${editor.vim.vimStateMachine.toSimpleString()}") logger.debug("None of carets have selection. State before adjustment: ${editor.vim.mode}")
if (editor.vim.inVisualMode) editor.vim.exitVisualMode() if (editor.vim.inVisualMode) editor.vim.exitVisualMode()
if (editor.vim.inSelectMode) editor.exitSelectMode(false) if (editor.vim.inSelectMode) editor.exitSelectMode(false)
if (editor.vim.mode.inNormalMode) { if (editor.vim.inNormalMode) {
activateMode(editor, chooseNonSelectionMode(editor)) activateMode(editor, chooseNonSelectionMode(editor))
} }
} }
@ -100,7 +100,7 @@ internal object IdeaSelectionControl {
* This method is created to improve user experience. It allows avoiding delay in some operations * This method is created to improve user experience. It allows avoiding delay in some operations
* (because [controlNonVimSelectionChange] is not executed immediately) * (because [controlNonVimSelectionChange] is not executed immediately)
*/ */
fun predictMode(editor: Editor, selectionSource: VimListenerManager.SelectionSource): VimStateMachine.Mode { fun predictMode(editor: Editor, selectionSource: VimListenerManager.SelectionSource): Mode {
if (editor.selectionModel.hasSelection(true)) { if (editor.selectionModel.hasSelection(true)) {
if (dontChangeMode(editor)) return editor.vim.mode if (dontChangeMode(editor)) return editor.vim.mode
return chooseSelectionMode(editor, selectionSource, false) return chooseSelectionMode(editor, selectionSource, false)
@ -109,17 +109,14 @@ internal object IdeaSelectionControl {
} }
} }
private fun activateMode(editor: Editor, mode: VimStateMachine.Mode) { private fun activateMode(editor: Editor, mode: Mode) {
when (mode) { when (mode) {
VimStateMachine.Mode.VISUAL -> VimPlugin.getVisualMotion() is Mode.VISUAL -> VimPlugin.getVisualMotion().enterVisualMode(editor.vim, mode.selectionType)
.enterVisualMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim)) is Mode.SELECT -> VimPlugin.getVisualMotion().enterSelectMode(editor.vim, mode.selectionType)
VimStateMachine.Mode.SELECT -> VimPlugin.getVisualMotion() is Mode.INSERT -> VimPlugin.getChange()
.enterSelectMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim)) .insertBeforeCursor(editor.vim, injector.executionContextManager.onEditor(editor.vim))
VimStateMachine.Mode.INSERT -> VimPlugin.getChange().insertBeforeCursor(
editor.vim, is Mode.NORMAL -> Unit
injector.executionContextManager.onEditor(editor.vim),
)
VimStateMachine.Mode.COMMAND -> Unit
else -> error("Unexpected mode: $mode") else -> error("Unexpected mode: $mode")
} }
} }
@ -127,40 +124,40 @@ internal object IdeaSelectionControl {
private fun dontChangeMode(editor: Editor): Boolean = private fun dontChangeMode(editor: Editor): Boolean =
editor.isTemplateActive() && (editor.vim.isIdeaRefactorModeKeep || editor.vim.mode.hasVisualSelection) editor.isTemplateActive() && (editor.vim.isIdeaRefactorModeKeep || editor.vim.mode.hasVisualSelection)
private fun chooseNonSelectionMode(editor: Editor): VimStateMachine.Mode { private fun chooseNonSelectionMode(editor: Editor): Mode {
val templateActive = editor.isTemplateActive() val templateActive = editor.isTemplateActive()
if (templateActive && editor.vim.mode.inNormalMode || editor.inInsertMode) { if (templateActive && editor.vim.mode.inNormalMode || editor.inInsertMode) {
return VimStateMachine.Mode.INSERT return Mode.INSERT
} }
return VimStateMachine.Mode.COMMAND return Mode.NORMAL()
} }
private fun chooseSelectionMode( private fun chooseSelectionMode(
editor: Editor, editor: Editor,
selectionSource: VimListenerManager.SelectionSource, selectionSource: VimListenerManager.SelectionSource,
logReason: Boolean, logReason: Boolean,
): VimStateMachine.Mode { ): Mode {
val selectmode = injector.options(editor.vim).selectmode val selectmode = injector.options(editor.vim).selectmode
return when { return when {
editor.isOneLineMode -> { editor.isOneLineMode -> {
if (logReason) logger.debug("Enter select mode. Reason: one line mode") if (logReason) logger.debug("Enter select mode. Reason: one line mode")
VimStateMachine.Mode.SELECT Mode.SELECT(VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
} }
selectionSource == VimListenerManager.SelectionSource.MOUSE && OptionConstants.selectmode_mouse in selectmode -> { selectionSource == VimListenerManager.SelectionSource.MOUSE && OptionConstants.selectmode_mouse in selectmode -> {
if (logReason) logger.debug("Enter select mode. Selection source is mouse and selectMode option has mouse") if (logReason) logger.debug("Enter select mode. Selection source is mouse and selectMode option has mouse")
VimStateMachine.Mode.SELECT Mode.SELECT(VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
} }
editor.isTemplateActive() && editor.vim.isIdeaRefactorModeSelect -> { editor.isTemplateActive() && editor.vim.isIdeaRefactorModeSelect -> {
if (logReason) logger.debug("Enter select mode. Template is active and selectMode has template") if (logReason) logger.debug("Enter select mode. Template is active and selectMode has template")
VimStateMachine.Mode.SELECT Mode.SELECT(VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
} }
selectionSource == VimListenerManager.SelectionSource.OTHER && OptionConstants.selectmode_ideaselection in selectmode -> { selectionSource == VimListenerManager.SelectionSource.OTHER && OptionConstants.selectmode_ideaselection in selectmode -> {
if (logReason) logger.debug("Enter select mode. Selection source is OTHER and selectMode has refactoring") if (logReason) logger.debug("Enter select mode. Selection source is OTHER and selectMode has refactoring")
VimStateMachine.Mode.SELECT Mode.SELECT(VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
} }
else -> { else -> {
if (logReason) logger.debug("Enter visual mode") if (logReason) logger.debug("Enter visual mode")
VimStateMachine.Mode.VISUAL Mode.VISUAL(VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
} }
} }
} }

View File

@ -9,7 +9,7 @@
package com.maddyhome.idea.vim.group.visual package com.maddyhome.idea.vim.group.visual
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.group.visual.VimVisualTimer.mode import com.maddyhome.idea.vim.group.visual.VimVisualTimer.mode
import com.maddyhome.idea.vim.group.visual.VimVisualTimer.singleTask import com.maddyhome.idea.vim.group.visual.VimVisualTimer.singleTask
import com.maddyhome.idea.vim.newapi.globalIjOptions import com.maddyhome.idea.vim.newapi.globalIjOptions
@ -55,9 +55,9 @@ import javax.swing.Timer
internal object VimVisualTimer { internal object VimVisualTimer {
var swingTimer: Timer? = null var swingTimer: Timer? = null
var mode: VimStateMachine.Mode? = null var mode: Mode? = null
inline fun singleTask(currentMode: VimStateMachine.Mode, crossinline task: (initialMode: VimStateMachine.Mode?) -> Unit) { inline fun singleTask(currentMode: Mode, crossinline task: (initialMode: Mode?) -> Unit) {
swingTimer?.stop() swingTimer?.stop()
if (mode == null) mode = currentMode if (mode == null) mode = currentMode
@ -79,7 +79,7 @@ internal object VimVisualTimer {
} }
} }
inline fun timerAction(task: (initialMode: VimStateMachine.Mode?) -> Unit) { inline fun timerAction(task: (initialMode: Mode?) -> Unit) {
task(mode) task(mode)
swingTimer = null swingTimer = null
mode = null mode = null

View File

@ -12,16 +12,16 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.api.getLineEndForOffset import com.maddyhome.idea.vim.api.getLineEndForOffset
import com.maddyhome.idea.vim.api.getLineStartForOffset import com.maddyhome.idea.vim.api.getLineStartForOffset
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.helper.inBlockSubMode import com.maddyhome.idea.vim.state.mode.inBlockSelection
import com.maddyhome.idea.vim.helper.isEndAllowed import com.maddyhome.idea.vim.helper.isEndAllowed
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.vimSelectionStart import com.maddyhome.idea.vim.helper.vimSelectionStart
import com.maddyhome.idea.vim.newapi.IjVimEditor import com.maddyhome.idea.vim.newapi.IjVimEditor
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
internal fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode: VimStateMachine.Mode) { internal fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode: Mode) {
if (predictedMode != VimStateMachine.Mode.VISUAL) { if (predictedMode !is Mode.VISUAL) {
if (!editor.vim.isEndAllowed(predictedMode)) { if (!editor.vim.isEndAllowed(predictedMode)) {
editor.caretModel.allCarets.forEach { caret -> editor.caretModel.allCarets.forEach { caret ->
val lineEnd = IjVimEditor(editor).getLineEndForOffset(caret.offset) val lineEnd = IjVimEditor(editor).getLineEndForOffset(caret.offset)
@ -49,5 +49,5 @@ internal fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode:
internal fun Caret.vimSetSelection(start: Int, end: Int = start, moveCaretToSelectionEnd: Boolean = false) { internal fun Caret.vimSetSelection(start: Int, end: Int = start, moveCaretToSelectionEnd: Boolean = false) {
vimSelectionStart = start vimSelectionStart = start
setVisualSelection(start, end, this.vim) setVisualSelection(start, end, this.vim)
if (moveCaretToSelectionEnd && !editor.vim.inBlockSubMode) moveToInlayAwareOffset(end) if (moveCaretToSelectionEnd && !editor.vim.inBlockSelection) moveToInlayAwareOffset(end)
} }

View File

@ -13,7 +13,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.VimVisualMotionGroupBase import com.maddyhome.idea.vim.api.VimVisualMotionGroupBase
import com.maddyhome.idea.vim.command.CommandState import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.command.engine import com.maddyhome.idea.vim.command.engine
import com.maddyhome.idea.vim.newapi.ij import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
@ -22,11 +22,11 @@ import com.maddyhome.idea.vim.newapi.vim
* @author Alex Plate * @author Alex Plate
*/ */
internal class VisualMotionGroup : VimVisualMotionGroupBase() { internal class VisualMotionGroup : VimVisualMotionGroupBase() {
override fun autodetectVisualSubmode(editor: VimEditor): VimStateMachine.SubMode { override fun autodetectVisualSubmode(editor: VimEditor): SelectionType {
// IJ specific. See https://youtrack.jetbrains.com/issue/VIM-1924. // IJ specific. See https://youtrack.jetbrains.com/issue/VIM-1924.
val project = editor.ij.project val project = editor.ij.project
if (project != null && FindManager.getInstance(project).selectNextOccurrenceWasPerformed()) { if (project != null && FindManager.getInstance(project).selectNextOccurrenceWasPerformed()) {
return VimStateMachine.SubMode.VISUAL_CHARACTER return SelectionType.CHARACTER_WISE
} }
return super.autodetectVisualSubmode(editor) return super.autodetectVisualSubmode(editor)

View File

@ -16,13 +16,14 @@ import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
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
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.newapi.ij import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.EffectiveOptionValueChangeListener import com.maddyhome.idea.vim.options.EffectiveOptionValueChangeListener
import com.maddyhome.idea.vim.options.helpers.GuiCursorMode import com.maddyhome.idea.vim.options.helpers.GuiCursorMode
import com.maddyhome.idea.vim.options.helpers.GuiCursorOptionHelper import com.maddyhome.idea.vim.options.helpers.GuiCursorOptionHelper
import com.maddyhome.idea.vim.options.helpers.GuiCursorType import com.maddyhome.idea.vim.options.helpers.GuiCursorType
import com.maddyhome.idea.vim.state.mode.inBlockSelection
import com.maddyhome.idea.vim.state.mode.mode
import org.jetbrains.annotations.TestOnly import org.jetbrains.annotations.TestOnly
import java.awt.Color import java.awt.Color
@ -66,28 +67,7 @@ internal object GuicursorChangeListener : EffectiveOptionValueChangeListener {
} }
private fun Editor.guicursorMode(): GuiCursorMode { private fun Editor.guicursorMode(): GuiCursorMode {
if (this.vim.vimStateMachine.isReplaceCharacter) { return GuiCursorMode.fromMode(vim.mode, vim.vimStateMachine.isReplaceCharacter)
// Can be true for NORMAL and VISUAL
return GuiCursorMode.REPLACE
}
// Note that Vim does not change the caret for SELECT mode and continues to use VISUAL or VISUAL_EXCLUSIVE. IdeaVim
// makes much more use of SELECT than Vim does (e.g. it's the default for idearefactormode) so it makes sense for us
// to more visually distinguish VISUAL and SELECT. So we use INSERT; a selection and the insert caret is intuitively
// the same as SELECT
return when (vim.mode) {
VimStateMachine.Mode.COMMAND -> GuiCursorMode.NORMAL
VimStateMachine.Mode.VISUAL -> GuiCursorMode.VISUAL // TODO: VISUAL_EXCLUSIVE
VimStateMachine.Mode.SELECT -> GuiCursorMode.INSERT
VimStateMachine.Mode.INSERT -> GuiCursorMode.INSERT
VimStateMachine.Mode.OP_PENDING -> GuiCursorMode.OP_PENDING
VimStateMachine.Mode.REPLACE -> GuiCursorMode.REPLACE
// This doesn't handle ci and cr, but we don't care - our CMD_LINE will never call this
VimStateMachine.Mode.CMD_LINE -> GuiCursorMode.CMD_LINE
VimStateMachine.Mode.INSERT_NORMAL -> GuiCursorMode.NORMAL
VimStateMachine.Mode.INSERT_VISUAL -> GuiCursorMode.VISUAL
VimStateMachine.Mode.INSERT_SELECT -> GuiCursorMode.INSERT
}
} }
/** /**
@ -107,7 +87,7 @@ private fun Editor.updatePrimaryCaretVisualAttributes() {
private fun Editor.updateSecondaryCaretsVisualAttributes() { private fun Editor.updateSecondaryCaretsVisualAttributes() {
// IntelliJ simulates visual block with multiple carets with selections. Do our best to hide them // IntelliJ simulates visual block with multiple carets with selections. Do our best to hide them
val attributes = if (this.vim.inBlockSubMode) HIDDEN else AttributesCache.getCaretVisualAttributes(this) val attributes = if (this.vim.inBlockSelection) HIDDEN else AttributesCache.getCaretVisualAttributes(this)
this.caretModel.allCarets.forEach { this.caretModel.allCarets.forEach {
if (it != this.caretModel.primaryCaret) { if (it != this.caretModel.primaryCaret) {
it.visualAttributes = attributes it.visualAttributes = attributes

View File

@ -15,20 +15,17 @@ import com.maddyhome.idea.vim.api.Options
import com.maddyhome.idea.vim.api.hasValue import com.maddyhome.idea.vim.api.hasValue
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.engine
import com.maddyhome.idea.vim.command.ij
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionScope import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.inVisualMode
import com.maddyhome.idea.vim.state.mode.mode
internal val VimStateMachine.Mode.hasVisualSelection internal val Mode.hasVisualSelection
get() = when (this) { get() = when (this) {
VimStateMachine.Mode.VISUAL, VimStateMachine.Mode.SELECT -> true is Mode.VISUAL, is Mode.SELECT -> true
VimStateMachine.Mode.REPLACE, VimStateMachine.Mode.CMD_LINE, VimStateMachine.Mode.COMMAND, VimStateMachine.Mode.INSERT, VimStateMachine.Mode.OP_PENDING -> false else -> false
VimStateMachine.Mode.INSERT_NORMAL -> false
VimStateMachine.Mode.INSERT_VISUAL -> true
VimStateMachine.Mode.INSERT_SELECT -> true
} }
/** /**
@ -36,7 +33,18 @@ internal val VimStateMachine.Mode.hasVisualSelection
* Please see: https://jb.gg/zo8n0r * Please see: https://jb.gg/zo8n0r
*/ */
public val Editor.mode: CommandState.Mode public val Editor.mode: CommandState.Mode
get() = this.vim.vimStateMachine.mode.ij get() {
val mode = this.vim.vimStateMachine.mode
return when (mode) {
Mode.CMD_LINE -> CommandState.Mode.CMD_LINE
Mode.INSERT -> CommandState.Mode.INSERT
is Mode.NORMAL -> CommandState.Mode.COMMAND
is Mode.OP_PENDING -> CommandState.Mode.OP_PENDING
Mode.REPLACE -> CommandState.Mode.REPLACE
is Mode.SELECT -> CommandState.Mode.SELECT
is Mode.VISUAL -> CommandState.Mode.VISUAL
}
}
/** /**
* COMPATIBILITY-LAYER: New method * COMPATIBILITY-LAYER: New method
@ -51,21 +59,24 @@ public val CommandState.Mode.isEndAllowed: Boolean
return injector.optionGroup.hasValue(Options.virtualedit, OptionScope.GLOBAL, OptionConstants.virtualedit_onemore) return injector.optionGroup.hasValue(Options.virtualedit, OptionScope.GLOBAL, OptionConstants.virtualedit_onemore)
} }
return when (this.engine) { return when (this) {
VimStateMachine.Mode.INSERT, VimStateMachine.Mode.VISUAL, VimStateMachine.Mode.SELECT -> true CommandState.Mode.INSERT, CommandState.Mode.VISUAL, CommandState.Mode.SELECT -> true
VimStateMachine.Mode.COMMAND, VimStateMachine.Mode.CMD_LINE, VimStateMachine.Mode.REPLACE, VimStateMachine.Mode.OP_PENDING -> possiblyUsesVirtualSpace() CommandState.Mode.COMMAND, CommandState.Mode.CMD_LINE, CommandState.Mode.REPLACE, CommandState.Mode.OP_PENDING -> possiblyUsesVirtualSpace()
VimStateMachine.Mode.INSERT_NORMAL, VimStateMachine.Mode.INSERT_VISUAL, VimStateMachine.Mode.INSERT_SELECT -> possiblyUsesVirtualSpace() CommandState.Mode.INSERT_NORMAL, CommandState.Mode.INSERT_VISUAL, CommandState.Mode.INSERT_SELECT -> possiblyUsesVirtualSpace()
} }
} }
@get:JvmName("inNormalMode") public val Mode.inNormalMode: Boolean
public val VimStateMachine.Mode.inNormalMode: Boolean get() = this is Mode.NORMAL
get() = this == VimStateMachine.Mode.COMMAND || this == VimStateMachine.Mode.INSERT_NORMAL
@get:JvmName("inInsertMode") @get:JvmName("inInsertMode")
public val Editor.inInsertMode: Boolean public val Editor.inInsertMode: Boolean
get() = this.vim.mode == VimStateMachine.Mode.INSERT || this.vim.mode == VimStateMachine.Mode.REPLACE get() = this.vim.mode == Mode.INSERT || this.vim.mode == Mode.REPLACE
@get:JvmName("inVisualMode") @get:JvmName("inVisualMode")
public val Editor.inVisualMode: Boolean public val Editor.inVisualMode: Boolean
get() = this.vim.mode.inVisualMode get() = this.vim.inVisualMode
@get:JvmName("inExMode")
internal val Editor.inExMode
get() = this.vim.vimStateMachine.mode is Mode.CMD_LINE

View File

@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key import com.intellij.openapi.util.Key
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.inBlockSelection
import java.util.stream.Collectors import java.util.stream.Collectors
/** /**
@ -63,7 +64,7 @@ internal fun <T : Comparable<T>> sort(a: T, b: T) = if (a > b) b to a else a to
// TODO Should be replaced with VimEditor.carets() // TODO Should be replaced with VimEditor.carets()
internal inline fun Editor.vimForEachCaret(action: (caret: Caret) -> Unit) { internal inline fun Editor.vimForEachCaret(action: (caret: Caret) -> Unit) {
if (this.vim.inBlockSubMode) { if (this.vim.inBlockSelection) {
action(this.caretModel.primaryCaret) action(this.caretModel.primaryCaret)
} else { } else {
this.caretModel.allCarets.forEach(action) this.caretModel.allCarets.forEach(action)

View File

@ -17,28 +17,34 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.getLineEndForOffset import com.maddyhome.idea.vim.api.getLineEndForOffset
import com.maddyhome.idea.vim.api.getLineStartForOffset import com.maddyhome.idea.vim.api.getLineStartForOffset
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
import com.maddyhome.idea.vim.newapi.IjEditorExecutionContext import com.maddyhome.idea.vim.newapi.IjEditorExecutionContext
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.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.Mode
/** import com.maddyhome.idea.vim.state.mode.ReturnTo
* Pop all modes, but leave editor state. E.g. editor selection is not removed. import com.maddyhome.idea.vim.state.mode.inSelectMode
*/ import com.maddyhome.idea.vim.state.mode.returnTo
internal fun Editor.popAllModes() {
val commandState = this.vim.vimStateMachine
while (commandState.mode != VimStateMachine.Mode.COMMAND) {
commandState.popModes()
}
}
/** [adjustCaretPosition] - if true, caret will be moved one char left if it's on the line end */ /** [adjustCaretPosition] - if true, caret will be moved one char left if it's on the line end */
internal fun Editor.exitSelectMode(adjustCaretPosition: Boolean) { internal fun Editor.exitSelectMode(adjustCaretPosition: Boolean) {
if (!this.vim.inSelectMode) return if (!this.vim.inSelectMode) return
this.vim.vimStateMachine.popModes() val returnTo = this.vim.vimStateMachine.mode.returnTo
when (returnTo) {
ReturnTo.INSERT -> {
this.vim.vimStateMachine.mode = Mode.INSERT
}
ReturnTo.REPLACE -> {
this.vim.vimStateMachine.mode = Mode.REPLACE
}
null -> {
this.vim.vimStateMachine.mode = Mode.NORMAL()
}
}
SelectionVimListenerSuppressor.lock().use { SelectionVimListenerSuppressor.lock().use {
this.caretModel.allCarets.forEach { this.caretModel.allCarets.forEach {
it.removeSelection() it.removeSelection()
@ -58,7 +64,20 @@ internal fun Editor.exitSelectMode(adjustCaretPosition: Boolean) {
internal fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) { internal fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) {
if (!this.inSelectMode) return if (!this.inSelectMode) return
this.vimStateMachine.popModes() val returnTo = this.vimStateMachine.mode.returnTo
when (returnTo) {
ReturnTo.INSERT -> {
this.vimStateMachine.mode = Mode.INSERT
}
ReturnTo.REPLACE -> {
this.vimStateMachine.mode = Mode.REPLACE
}
null -> {
this.vimStateMachine.mode = Mode.NORMAL()
}
}
SelectionVimListenerSuppressor.lock().use { SelectionVimListenerSuppressor.lock().use {
this.carets().forEach { vimCaret -> this.carets().forEach { vimCaret ->
val caret = (vimCaret as IjVimCaret).caret val caret = (vimCaret as IjVimCaret).caret

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.normalizeVisualColumn import com.maddyhome.idea.vim.api.normalizeVisualColumn
import com.maddyhome.idea.vim.api.options import com.maddyhome.idea.vim.api.options
import com.maddyhome.idea.vim.command.CommandFlags import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.VimStateMachine
import com.maddyhome.idea.vim.helper.EditorHelper.getApproximateScreenHeight import com.maddyhome.idea.vim.helper.EditorHelper.getApproximateScreenHeight
import com.maddyhome.idea.vim.helper.EditorHelper.getApproximateScreenWidth import com.maddyhome.idea.vim.helper.EditorHelper.getApproximateScreenWidth
import com.maddyhome.idea.vim.helper.EditorHelper.getNonNormalizedVisualLineAtBottomOfScreen import com.maddyhome.idea.vim.helper.EditorHelper.getNonNormalizedVisualLineAtBottomOfScreen

View File

@ -23,7 +23,8 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.maddyhome.idea.vim.VimPlugin; import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.api.EngineEditorHelperKt; import com.maddyhome.idea.vim.api.EngineEditorHelperKt;
import com.maddyhome.idea.vim.api.VimEditor; import com.maddyhome.idea.vim.api.VimEditor;
import com.maddyhome.idea.vim.command.VimStateMachine; import com.maddyhome.idea.vim.state.mode.Mode;
import com.maddyhome.idea.vim.state.VimStateMachine;
import com.maddyhome.idea.vim.common.CharacterPosition; import com.maddyhome.idea.vim.common.CharacterPosition;
import com.maddyhome.idea.vim.common.Direction; import com.maddyhome.idea.vim.common.Direction;
import com.maddyhome.idea.vim.common.TextRange; import com.maddyhome.idea.vim.common.TextRange;
@ -858,8 +859,8 @@ public class SearchHelper {
selectionEndWithoutNewline++; selectionEndWithoutNewline++;
} }
final VimStateMachine.Mode mode = VimStateMachine.getInstance(new IjVimEditor(editor)).getMode(); final Mode mode = VimStateMachine.Companion.getInstance(new IjVimEditor(editor)).getMode();
if (mode == VimStateMachine.Mode.VISUAL) { if (mode instanceof Mode.VISUAL) {
if (closingTagTextRange.getStartOffset() == selectionEndWithoutNewline && if (closingTagTextRange.getStartOffset() == selectionEndWithoutNewline &&
openingTag.getEndOffset() == selectionStart) { openingTag.getEndOffset() == selectionStart) {
// Special case: if the inner tag is already selected we should like isOuter is active // Special case: if the inner tag is already selected we should like isOuter is active

View File

@ -21,8 +21,9 @@ import com.intellij.openapi.util.UserDataHolder
import com.maddyhome.idea.vim.api.CaretRegisterStorageBase import com.maddyhome.idea.vim.api.CaretRegisterStorageBase
import com.maddyhome.idea.vim.api.LocalMarkStorage import com.maddyhome.idea.vim.api.LocalMarkStorage
import com.maddyhome.idea.vim.api.SelectionInfo import com.maddyhome.idea.vim.api.SelectionInfo
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.state.VimStateMachine
import com.maddyhome.idea.vim.ex.ExOutputModel import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.group.visual.VisualChange import com.maddyhome.idea.vim.group.visual.VisualChange
import com.maddyhome.idea.vim.group.visual.vimLeadSelectionOffset import com.maddyhome.idea.vim.group.visual.vimLeadSelectionOffset
@ -127,7 +128,7 @@ internal var Editor.vimTestInputModel: TestInputModel? by userData()
* Checks whether a keeping visual mode visual operator action is performed on editor. * Checks whether a keeping visual mode visual operator action is performed on editor.
*/ */
internal var Editor.vimKeepingVisualOperatorAction: Boolean by userDataOr { false } internal var Editor.vimKeepingVisualOperatorAction: Boolean by userDataOr { false }
internal var Editor.vimChangeActionSwitchMode: VimStateMachine.Mode? by userData() internal var Editor.vimChangeActionSwitchMode: Mode? by userData()
/** /**
* Function for delegated properties. * Function for delegated properties.

View File

@ -33,14 +33,13 @@ import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.VimShortcutKeyAction import com.maddyhome.idea.vim.action.VimShortcutKeyAction
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.group.NotificationService import com.maddyhome.idea.vim.group.NotificationService
import com.maddyhome.idea.vim.helper.inNormalMode
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.globalIjOptions import com.maddyhome.idea.vim.newapi.globalIjOptions
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.inNormalMode
import com.maddyhome.idea.vim.vimscript.model.options.helpers.IdeaRefactorModeHelper import com.maddyhome.idea.vim.vimscript.model.options.helpers.IdeaRefactorModeHelper
import com.maddyhome.idea.vim.vimscript.model.options.helpers.isIdeaRefactorModeKeep import com.maddyhome.idea.vim.vimscript.model.options.helpers.isIdeaRefactorModeKeep
import org.jetbrains.annotations.NonNls import org.jetbrains.annotations.NonNls
@ -125,9 +124,7 @@ internal object IdeaSpecifics {
) { ) {
editor?.let { editor?.let {
val commandState = it.vim.vimStateMachine val commandState = it.vim.vimStateMachine
while (commandState.mode != VimStateMachine.Mode.COMMAND) { commandState.mode = Mode.NORMAL()
commandState.popModes()
}
VimPlugin.getChange().insertBeforeCursor(it.vim, event.dataContext.vim) VimPlugin.getChange().insertBeforeCursor(it.vim, event.dataContext.vim)
KeyHandler.getInstance().reset(it.vim) KeyHandler.getInstance().reset(it.vim)
} }
@ -163,7 +160,7 @@ internal object IdeaSpecifics {
if (!editor.selectionModel.hasSelection()) { if (!editor.selectionModel.hasSelection()) {
// Enable insert mode if there is no selection in template // Enable insert mode if there is no selection in template
// Template with selection is handled by [com.maddyhome.idea.vim.group.visual.VisualMotionGroup.controlNonVimSelectionChange] // Template with selection is handled by [com.maddyhome.idea.vim.group.visual.VisualMotionGroup.controlNonVimSelectionChange]
if (editor.vim.mode.inNormalMode) { if (editor.vim.inNormalMode) {
VimPlugin.getChange().insertBeforeCursor( VimPlugin.getChange().insertBeforeCursor(
editor.vim, editor.vim,
injector.executionContextManager.onEditor(editor.vim), injector.executionContextManager.onEditor(editor.vim),

View File

@ -44,7 +44,6 @@ import com.maddyhome.idea.vim.api.Options
import com.maddyhome.idea.vim.api.getLineEndForOffset import com.maddyhome.idea.vim.api.getLineEndForOffset
import com.maddyhome.idea.vim.api.getLineStartForOffset import com.maddyhome.idea.vim.api.getLineStartForOffset
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.ex.ExOutputModel import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.group.EditorGroup import com.maddyhome.idea.vim.group.EditorGroup
import com.maddyhome.idea.vim.group.FileGroup import com.maddyhome.idea.vim.group.FileGroup
@ -61,14 +60,12 @@ import com.maddyhome.idea.vim.helper.VimStandalonePluginUpdateChecker
import com.maddyhome.idea.vim.helper.exitSelectMode import com.maddyhome.idea.vim.helper.exitSelectMode
import com.maddyhome.idea.vim.helper.exitVisualMode import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.helper.forceBarCursor import com.maddyhome.idea.vim.helper.forceBarCursor
import com.maddyhome.idea.vim.helper.inSelectMode
import com.maddyhome.idea.vim.helper.inVisualMode import com.maddyhome.idea.vim.helper.inVisualMode
import com.maddyhome.idea.vim.helper.isEndAllowed import com.maddyhome.idea.vim.helper.isEndAllowed
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.localEditors import com.maddyhome.idea.vim.helper.localEditors
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.resetVimLastColumn import com.maddyhome.idea.vim.helper.resetVimLastColumn
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
import com.maddyhome.idea.vim.helper.vimDisabled import com.maddyhome.idea.vim.helper.vimDisabled
import com.maddyhome.idea.vim.listener.MouseEventsDataHolder.skipEvents import com.maddyhome.idea.vim.listener.MouseEventsDataHolder.skipEvents
@ -76,6 +73,9 @@ import com.maddyhome.idea.vim.listener.MouseEventsDataHolder.skipNDragEvents
import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.add import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.add
import com.maddyhome.idea.vim.newapi.IjVimEditor import com.maddyhome.idea.vim.newapi.IjVimEditor
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.inSelectMode
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.state.mode.selectionType
import com.maddyhome.idea.vim.ui.ShowCmdOptionChangeListener import com.maddyhome.idea.vim.ui.ShowCmdOptionChangeListener
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
import java.awt.event.MouseAdapter import java.awt.event.MouseAdapter
@ -447,7 +447,7 @@ internal object VimListenerManager {
ExOutputModel.getInstance(editor).clear() ExOutputModel.getInstance(editor).clear()
val caretModel = editor.caretModel val caretModel = editor.caretModel
if (editor.vim.subMode != VimStateMachine.SubMode.NONE) { if (editor.vim.mode.selectionType != null) {
caretModel.removeSecondaryCarets() caretModel.removeSecondaryCarets()
} }

View File

@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.api.VimCaret
import com.maddyhome.idea.vim.api.VimCaretBase import com.maddyhome.idea.vim.api.VimCaretBase
import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.VimVisualPosition import com.maddyhome.idea.vim.api.VimVisualPosition
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.EditorLine import com.maddyhome.idea.vim.common.EditorLine
import com.maddyhome.idea.vim.common.LiveRange import com.maddyhome.idea.vim.common.LiveRange
import com.maddyhome.idea.vim.common.Offset import com.maddyhome.idea.vim.common.Offset

View File

@ -34,9 +34,9 @@ import com.maddyhome.idea.vim.api.VimScrollingModel
import com.maddyhome.idea.vim.api.VimSelectionModel import com.maddyhome.idea.vim.api.VimSelectionModel
import com.maddyhome.idea.vim.api.VimVisualPosition import com.maddyhome.idea.vim.api.VimVisualPosition
import com.maddyhome.idea.vim.api.VirtualFile import com.maddyhome.idea.vim.api.VirtualFile
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.common.EditorLine import com.maddyhome.idea.vim.common.EditorLine
import com.maddyhome.idea.vim.common.IndentConfig import com.maddyhome.idea.vim.common.IndentConfig
import com.maddyhome.idea.vim.common.LiveRange import com.maddyhome.idea.vim.common.LiveRange
@ -50,7 +50,8 @@ import com.maddyhome.idea.vim.helper.exitInsertMode
import com.maddyhome.idea.vim.helper.exitSelectMode import com.maddyhome.idea.vim.helper.exitSelectMode
import com.maddyhome.idea.vim.helper.fileSize import com.maddyhome.idea.vim.helper.fileSize
import com.maddyhome.idea.vim.helper.getTopLevelEditor import com.maddyhome.idea.vim.helper.getTopLevelEditor
import com.maddyhome.idea.vim.helper.inBlockSubMode import com.maddyhome.idea.vim.state.mode.inBlockSelection
import com.maddyhome.idea.vim.helper.inExMode
import com.maddyhome.idea.vim.helper.isTemplateActive import com.maddyhome.idea.vim.helper.isTemplateActive
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
import com.maddyhome.idea.vim.helper.updateCaretsVisualPosition import com.maddyhome.idea.vim.helper.updateCaretsVisualPosition
@ -70,7 +71,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
val originalEditor = editor val originalEditor = editor
override val lfMakesNewLine: Boolean = true override val lfMakesNewLine: Boolean = true
override var vimChangeActionSwitchMode: VimStateMachine.Mode? override var vimChangeActionSwitchMode: Mode?
get() = editor.vimChangeActionSwitchMode get() = editor.vimChangeActionSwitchMode
set(value) { set(value) {
editor.vimChangeActionSwitchMode = value editor.vimChangeActionSwitchMode = value
@ -139,7 +140,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
} }
override fun carets(): List<VimCaret> { override fun carets(): List<VimCaret> {
return if (editor.vim.inBlockSubMode) { return if (editor.vim.inBlockSelection || (editor.inExMode && editor.vim.vimLastSelectionType == SelectionType.BLOCK_WISE)) {
listOf(IjVimCaret(editor.caretModel.primaryCaret)) listOf(IjVimCaret(editor.caretModel.primaryCaret))
} else { } else {
editor.caretModel.allCarets.map { IjVimCaret(it) } editor.caretModel.allCarets.map { IjVimCaret(it) }
@ -152,7 +153,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
@Suppress("ideavimRunForEachCaret") @Suppress("ideavimRunForEachCaret")
override fun forEachCaret(action: (VimCaret) -> Unit) { override fun forEachCaret(action: (VimCaret) -> Unit) {
if (editor.vim.inBlockSubMode) { if (editor.vim.inBlockSelection) {
action(IjVimCaret(editor.caretModel.primaryCaret)) action(IjVimCaret(editor.caretModel.primaryCaret))
} else { } else {
editor.caretModel.runForEachCaret({ action(IjVimCaret(it)) }, false) editor.caretModel.runForEachCaret({ action(IjVimCaret(it)) }, false)

View File

@ -53,7 +53,6 @@ import com.maddyhome.idea.vim.api.VimrcFileState
import com.maddyhome.idea.vim.api.VimscriptExecutor import com.maddyhome.idea.vim.api.VimscriptExecutor
import com.maddyhome.idea.vim.api.VimscriptFunctionService import com.maddyhome.idea.vim.api.VimscriptFunctionService
import com.maddyhome.idea.vim.api.VimscriptParser import com.maddyhome.idea.vim.api.VimscriptParser
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.diagnostic.VimLogger import com.maddyhome.idea.vim.diagnostic.VimLogger
import com.maddyhome.idea.vim.ex.ExOutputModel import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.extension.VimExtensionRegistrar import com.maddyhome.idea.vim.extension.VimExtensionRegistrar
@ -82,6 +81,8 @@ import com.maddyhome.idea.vim.history.VimHistory
import com.maddyhome.idea.vim.macro.VimMacro import com.maddyhome.idea.vim.macro.VimMacro
import com.maddyhome.idea.vim.put.VimPut import com.maddyhome.idea.vim.put.VimPut
import com.maddyhome.idea.vim.register.VimRegisterGroup import com.maddyhome.idea.vim.register.VimRegisterGroup
import com.maddyhome.idea.vim.state.VimStateMachine
import com.maddyhome.idea.vim.impl.state.VimStateMachineImpl
import com.maddyhome.idea.vim.ui.VimRcFileState import com.maddyhome.idea.vim.ui.VimRcFileState
import com.maddyhome.idea.vim.undo.VimUndoRedo import com.maddyhome.idea.vim.undo.VimUndoRedo
import com.maddyhome.idea.vim.vimscript.Executor import com.maddyhome.idea.vim.vimscript.Executor
@ -197,7 +198,7 @@ internal class IjVimInjector : VimInjectorBase() {
override fun commandStateFor(editor: VimEditor): VimStateMachine { override fun commandStateFor(editor: VimEditor): VimStateMachine {
var res = editor.ij.vimStateMachine var res = editor.ij.vimStateMachine
if (res == null) { if (res == null) {
res = VimStateMachine(editor) res = VimStateMachineImpl(editor)
editor.ij.vimStateMachine = res editor.ij.vimStateMachine = res
} }
return res return res

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.api.lineLength
import com.maddyhome.idea.vim.api.options import com.maddyhome.idea.vim.api.options
import com.maddyhome.idea.vim.api.visualLineToBufferLine import com.maddyhome.idea.vim.api.visualLineToBufferLine
import com.maddyhome.idea.vim.helper.EditorHelper import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.inVisualMode import com.maddyhome.idea.vim.state.mode.inVisualMode
import com.maddyhome.idea.vim.helper.vimLine import com.maddyhome.idea.vim.helper.vimLine
import com.maddyhome.idea.vim.newapi.ij import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.vimscript.model.VimLContext import com.maddyhome.idea.vim.vimscript.model.VimLContext

View File

@ -20,11 +20,13 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.group.IjOptionConstants import com.maddyhome.idea.vim.group.IjOptionConstants
import com.maddyhome.idea.vim.helper.hasBlockOrUnderscoreCaret import com.maddyhome.idea.vim.helper.hasBlockOrUnderscoreCaret
import com.maddyhome.idea.vim.helper.hasVisualSelection import com.maddyhome.idea.vim.helper.hasVisualSelection
import com.maddyhome.idea.vim.helper.mode import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
import com.maddyhome.idea.vim.newapi.ijOptions import com.maddyhome.idea.vim.newapi.ijOptions
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.state.mode.selectionType
public val VimEditor.isIdeaRefactorModeKeep: Boolean public val VimEditor.isIdeaRefactorModeKeep: Boolean
get() = injector.ijOptions(this).idearefactormode.contains(IjOptionConstants.idearefactormode_keep) get() = injector.ijOptions(this).idearefactormode.contains(IjOptionConstants.idearefactormode_keep)
@ -36,16 +38,22 @@ internal object IdeaRefactorModeHelper {
fun correctSelection(editor: Editor) { fun correctSelection(editor: Editor) {
val action: () -> Unit = { val action: () -> Unit = {
if (!editor.vim.mode.hasVisualSelection && editor.selectionModel.hasSelection()) { val mode = editor.vim.mode
if (!mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
SelectionVimListenerSuppressor.lock().use { SelectionVimListenerSuppressor.lock().use {
editor.selectionModel.removeSelection() editor.selectionModel.removeSelection()
} }
} }
if (editor.vim.mode.hasVisualSelection && editor.selectionModel.hasSelection()) { if (mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
val autodetectedSubmode = VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim) val autodetectedSubmode = VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim)
if (editor.vim.subMode != autodetectedSubmode) { if (mode.selectionType != autodetectedSubmode) {
// Update the submode // Update the submode
editor.vim.subMode = autodetectedSubmode val newMode = when (mode) {
is Mode.SELECT -> mode.copy(selectionType = autodetectedSubmode)
is Mode.VISUAL -> mode.copy(selectionType = autodetectedSubmode)
else -> error("IdeaVim should be either in visual or select modes")
}
editor.vim.vimStateMachine.mode = newMode
} }
} }

View File

@ -15,7 +15,6 @@ import com.ensarsarajcic.neovim.java.corerpc.client.ProcessRpcConnection
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.LogicalPosition import com.intellij.openapi.editor.LogicalPosition
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.common.CharacterPosition import com.maddyhome.idea.vim.common.CharacterPosition
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
@ -28,6 +27,8 @@ import com.maddyhome.idea.vim.register.RegisterConstants.EXPRESSION_BUFFER_REGIS
import com.maddyhome.idea.vim.register.RegisterConstants.LAST_INSERTED_TEXT_REGISTER import com.maddyhome.idea.vim.register.RegisterConstants.LAST_INSERTED_TEXT_REGISTER
import com.maddyhome.idea.vim.register.RegisterConstants.LAST_SEARCH_REGISTER import com.maddyhome.idea.vim.register.RegisterConstants.LAST_SEARCH_REGISTER
import com.maddyhome.idea.vim.register.RegisterConstants.VALID_REGISTERS import com.maddyhome.idea.vim.register.RegisterConstants.VALID_REGISTERS
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.state.mode.toVimNotation
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.jupiter.api.TestInfo import org.junit.jupiter.api.TestInfo
@ -159,9 +160,11 @@ internal object NeovimTesting {
assertEquals(neovimContent, editor.document.text) assertEquals(neovimContent, editor.document.text)
} }
public fun vimMode() = neovimApi.mode.get().mode
private fun assertMode(editor: Editor) { private fun assertMode(editor: Editor) {
val ideavimState = editor.vim.vimStateMachine.toVimNotation() val ideavimState = editor.vim.vimStateMachine.mode.toVimNotation()
val neovimState = neovimApi.mode.get().mode val neovimState = vimMode()
assertEquals(neovimState, ideavimState) assertEquals(neovimState, ideavimState)
} }
@ -178,7 +181,7 @@ internal object NeovimTesting {
for (register in VALID_REGISTERS) { for (register in VALID_REGISTERS) {
if (register in nonCheckingRegisters) continue if (register in nonCheckingRegisters) continue
if (register in VimTestCase.Checks.neoVim.ignoredRegisters) continue if (register in VimTestCase.Checks.neoVim.ignoredRegisters) continue
val neovimRegister = neovimApi.callFunction("getreg", listOf(register)).get().toString() val neovimRegister = getRegister(register)
val vimPluginRegister = VimPlugin.getRegister().getRegister(register) val vimPluginRegister = VimPlugin.getRegister().getRegister(register)
val ideavimRegister = vimPluginRegister?.text ?: "" val ideavimRegister = vimPluginRegister?.text ?: ""
assertEquals("Register '$register'", neovimRegister, ideavimRegister) assertEquals("Register '$register'", neovimRegister, ideavimRegister)
@ -198,6 +201,9 @@ internal object NeovimTesting {
} }
} }
} }
public fun getRegister(register: Char) = neovimApi.callFunction("getreg", listOf(register)).get().toString()
public fun getMark(register: String) = neovimApi.callFunction("getpos", listOf(register)).get().toString()
} }
annotation class TestWithoutNeovim(val reason: SkipNeovimReason, val description: String = "") annotation class TestWithoutNeovim(val reason: SkipNeovimReason, val description: String = "")

View File

@ -11,7 +11,7 @@ package org.jetbrains.plugins.ideavim
import com.maddyhome.idea.vim.RegisterActions.VIM_ACTIONS_EP import com.maddyhome.idea.vim.RegisterActions.VIM_ACTIONS_EP
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.handler.ActionBeanClass import com.maddyhome.idea.vim.handler.ActionBeanClass
import com.maddyhome.idea.vim.key.CommandNode import com.maddyhome.idea.vim.key.CommandNode
import com.maddyhome.idea.vim.key.CommandPartNode import com.maddyhome.idea.vim.key.CommandPartNode
@ -29,7 +29,7 @@ class RegisterActionsTest : VimTestCase() {
fun `test simple action`() { fun `test simple action`() {
val before = "I ${c}found it in a legendary land" val before = "I ${c}found it in a legendary land"
val after = "I f${c}ound it in a legendary land" val after = "I f${c}ound it in a legendary land"
doTest("l", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("l", before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(reason = SkipNeovimReason.EDITOR_MODIFICATION) @TestWithoutNeovim(reason = SkipNeovimReason.EDITOR_MODIFICATION)
@ -41,7 +41,7 @@ class RegisterActionsTest : VimTestCase() {
} }
val before = "I ${c}found it in a legendary land" val before = "I ${c}found it in a legendary land"
val after = "I jklwB${c}found it in a legendary land" val after = "I jklwB${c}found it in a legendary land"
doTest("jklwB", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) { doTest("jklwB", before, after, Mode.NORMAL()) {
VimPlugin.setEnabled(false) VimPlugin.setEnabled(false)
} }
} finally { } finally {
@ -57,7 +57,7 @@ class RegisterActionsTest : VimTestCase() {
fun `test turn plugin off and on`() { fun `test turn plugin off and on`() {
val before = "I ${c}found it in a legendary land" val before = "I ${c}found it in a legendary land"
val after = "I f${c}ound it in a legendary land" val after = "I f${c}ound it in a legendary land"
doTest("l", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) { doTest("l", before, after, Mode.NORMAL()) {
VimPlugin.setEnabled(false) VimPlugin.setEnabled(false)
VimPlugin.setEnabled(true) VimPlugin.setEnabled(true)
} }
@ -71,7 +71,7 @@ class RegisterActionsTest : VimTestCase() {
fun `test enable twice`() { fun `test enable twice`() {
val before = "I ${c}found it in a legendary land" val before = "I ${c}found it in a legendary land"
val after = "I f${c}ound it in a legendary land" val after = "I f${c}ound it in a legendary land"
doTest("l", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) { doTest("l", before, after, Mode.NORMAL()) {
VimPlugin.setEnabled(false) VimPlugin.setEnabled(false)
VimPlugin.setEnabled(true) VimPlugin.setEnabled(true)
VimPlugin.setEnabled(true) VimPlugin.setEnabled(true)
@ -87,7 +87,7 @@ class RegisterActionsTest : VimTestCase() {
val before = "I ${c}found it in a legendary land" val before = "I ${c}found it in a legendary land"
val after = "I f${c}ound it in a legendary land" val after = "I f${c}ound it in a legendary land"
var motionRightAction: ActionBeanClass? = null var motionRightAction: ActionBeanClass? = null
doTest("l", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) { doTest("l", before, after, Mode.NORMAL()) {
motionRightAction = motionRightAction =
VIM_ACTIONS_EP.getExtensionList(null).first { it.actionId == "VimPreviousTabAction" } VIM_ACTIONS_EP.getExtensionList(null).first { it.actionId == "VimPreviousTabAction" }

View File

@ -15,9 +15,9 @@ import com.intellij.testFramework.EditorTestUtil
import com.intellij.testFramework.fixtures.CodeInsightTestFixture import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import com.intellij.util.containers.toArray import com.intellij.util.containers.toArray
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.helper.mode import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.newapi.globalIjOptions import com.maddyhome.idea.vim.newapi.globalIjOptions
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.Arguments
@ -68,7 +68,7 @@ inline fun waitAndAssert(timeInMillis: Int = 1000, condition: () -> Boolean) {
fun waitAndAssertMode( fun waitAndAssertMode(
fixture: CodeInsightTestFixture, fixture: CodeInsightTestFixture,
mode: VimStateMachine.Mode, mode: Mode,
timeInMillis: Int? = null, timeInMillis: Int? = null,
) { ) {
val timeout = timeInMillis ?: (injector.globalIjOptions().visualdelay + 1000) val timeout = timeInMillis ?: (injector.globalIjOptions().visualdelay + 1000)

View File

@ -48,8 +48,7 @@ import com.maddyhome.idea.vim.api.options
import com.maddyhome.idea.vim.api.setToggleOption import com.maddyhome.idea.vim.api.setToggleOption
import com.maddyhome.idea.vim.api.visualLineToBufferLine import com.maddyhome.idea.vim.api.visualLineToBufferLine
import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.VimStateMachine.SubMode
import com.maddyhome.idea.vim.ex.ExException import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ExOutputModel.Companion.getInstance import com.maddyhome.idea.vim.ex.ExOutputModel.Companion.getInstance
import com.maddyhome.idea.vim.group.GlobalIjOptions import com.maddyhome.idea.vim.group.GlobalIjOptions
@ -59,9 +58,8 @@ import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.RunnableHelper.runWriteCommand import com.maddyhome.idea.vim.helper.RunnableHelper.runWriteCommand
import com.maddyhome.idea.vim.helper.TestInputModel import com.maddyhome.idea.vim.helper.TestInputModel
import com.maddyhome.idea.vim.helper.getGuiCursorMode import com.maddyhome.idea.vim.helper.getGuiCursorMode
import com.maddyhome.idea.vim.helper.inBlockSubMode import com.maddyhome.idea.vim.state.mode.inBlockSelection
import com.maddyhome.idea.vim.helper.mode import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.key.MappingOwner import com.maddyhome.idea.vim.key.MappingOwner
import com.maddyhome.idea.vim.key.ToKeysMappingInfo import com.maddyhome.idea.vim.key.ToKeysMappingInfo
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
@ -263,6 +261,13 @@ abstract class VimTestCase {
return fixture.editor return fixture.editor
} }
public fun configureByTextX(fileName: String, content: String): Editor {
fixture.configureByText(fileName, content)
NeovimTesting.setupEditor(fixture.editor, testInfo)
setEditorVisibleSize(screenWidth, screenHeight)
return fixture.editor
}
protected fun configureByFileName(fileName: String): Editor { protected fun configureByFileName(fileName: String): Editor {
fixture.configureByText(fileName, "\n") fixture.configureByText(fileName, "\n")
NeovimTesting.setupEditor(fixture.editor, testInfo) NeovimTesting.setupEditor(fixture.editor, testInfo)
@ -393,9 +398,16 @@ abstract class VimTestCase {
NeovimTesting.assertState(fixture.editor, testInfo) NeovimTesting.assertState(fixture.editor, testInfo)
} }
protected fun assertState(modeAfter: VimStateMachine.Mode, subModeAfter: SubMode) { fun mode(): String? {
return NeovimTesting.vimMode()
}
fun register(char: String): String? {
return NeovimTesting.getMark(char)
}
protected fun assertState(modeAfter: Mode) {
assertMode(modeAfter) assertMode(modeAfter)
assertSubMode(subModeAfter)
assertCaretsVisualAttributes() assertCaretsVisualAttributes()
} }
@ -517,16 +529,11 @@ abstract class VimTestCase {
} }
} }
fun assertMode(expectedMode: VimStateMachine.Mode) { fun assertMode(expectedMode: Mode) {
val mode = fixture.editor.vim.mode val mode = fixture.editor.vim.mode
assertEquals(expectedMode, mode) assertEquals(expectedMode, mode)
} }
fun assertSubMode(expectedSubMode: SubMode) {
val subMode = fixture.editor.vim.subMode
assertEquals(expectedSubMode, subMode)
}
fun assertSelection(expected: String?) { fun assertSelection(expected: String?) {
val selected = fixture.editor.selectionModel.selectedText val selected = fixture.editor.selectionModel.selectedText
assertEquals(expected, selected) assertEquals(expected, selected)
@ -565,7 +572,7 @@ abstract class VimTestCase {
editor.caretModel.allCarets.forEach { caret -> editor.caretModel.allCarets.forEach { caret ->
// All carets should be the same except when in block sub mode, where we "hide" them (by drawing a zero width bar) // All carets should be the same except when in block sub mode, where we "hide" them (by drawing a zero width bar)
if (caret !== editor.caretModel.primaryCaret && editor.vim.inBlockSubMode) { if (caret !== editor.caretModel.primaryCaret && editor.vim.inBlockSelection) {
assertEquals(CaretVisualAttributes.Shape.BAR, caret.visualAttributes.shape) assertEquals(CaretVisualAttributes.Shape.BAR, caret.visualAttributes.shape)
assertEquals(0F, caret.visualAttributes.thickness) assertEquals(0F, caret.visualAttributes.thickness)
} else { } else {
@ -591,8 +598,7 @@ abstract class VimTestCase {
keys: List<String>, keys: List<String>,
before: String, before: String,
after: String, after: String,
modeAfter: VimStateMachine.Mode = VimStateMachine.Mode.COMMAND, modeAfter: Mode = Mode.NORMAL(),
subModeAfter: SubMode = SubMode.NONE,
fileType: FileType? = null, fileType: FileType? = null,
fileName: String? = null, fileName: String? = null,
afterEditorInitialized: ((Editor) -> Unit)? = null, afterEditorInitialized: ((Editor) -> Unit)? = null,
@ -602,7 +608,6 @@ abstract class VimTestCase {
before, before,
after, after,
modeAfter, modeAfter,
subModeAfter,
fileType, fileType,
fileName, fileName,
afterEditorInitialized, afterEditorInitialized,
@ -614,8 +619,7 @@ abstract class VimTestCase {
keys: String, keys: String,
before: String, before: String,
after: String, after: String,
modeAfter: VimStateMachine.Mode = VimStateMachine.Mode.COMMAND, modeAfter: Mode = Mode.NORMAL(),
subModeAfter: SubMode = SubMode.NONE,
fileType: FileType? = null, fileType: FileType? = null,
fileName: String? = null, fileName: String? = null,
afterEditorInitialized: ((Editor) -> Unit)? = null, afterEditorInitialized: ((Editor) -> Unit)? = null,
@ -628,14 +632,14 @@ abstract class VimTestCase {
configureByText(before) configureByText(before)
} }
afterEditorInitialized?.invoke(fixture.editor) afterEditorInitialized?.invoke(fixture.editor)
performTest(keys, after, modeAfter, subModeAfter) performTest(keys, after, modeAfter)
} }
protected fun performTest(keys: String, after: String, modeAfter: VimStateMachine.Mode, subModeAfter: SubMode) { protected fun performTest(keys: String, after: String, modeAfter: Mode) {
typeText(keys) typeText(keys)
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue() PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
assertState(after) assertState(after)
assertState(modeAfter, subModeAfter) assertState(modeAfter)
} }
protected fun setRegister(register: Char, keys: String) { protected fun setRegister(register: Char, keys: String) {

View File

@ -10,7 +10,9 @@ package org.jetbrains.plugins.ideavim.action
import com.intellij.codeInsight.folding.CodeFoldingManager import com.intellij.codeInsight.folding.CodeFoldingManager
import com.intellij.codeInsight.folding.impl.FoldingUtil import com.intellij.codeInsight.folding.impl.FoldingUtil
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.ReturnTo
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -29,8 +31,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"), listOf("i", "<C-O>", "a", "123", "<Esc>", "x"),
"abc${c}d\n", "abc${c}d\n",
"abcd12\n", "abcd12\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -41,8 +42,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "o", "123", "<Esc>", "x"), listOf("i", "<C-O>", "o", "123", "<Esc>", "x"),
"abc${c}d\n", "abc${c}d\n",
"abcd\n12\n", "abcd\n12\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -53,8 +53,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v"), listOf("i", "<C-O>", "v"),
"12${c}345", "12${c}345",
"12${s}${c}3${se}45", "12${s}${c}3${se}45",
VimStateMachine.Mode.INSERT_VISUAL, Mode.VISUAL(SelectionType.CHARACTER_WISE, ReturnTo.INSERT)
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -65,8 +64,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v", "<esc>"), listOf("i", "<C-O>", "v", "<esc>"),
"12${c}345", "12${c}345",
"12${c}345", "12${c}345",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -77,8 +75,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v", "d"), listOf("i", "<C-O>", "v", "d"),
"12${c}345", "12${c}345",
"12${c}45", "12${c}45",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -90,8 +87,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v", "<C-G>"), listOf("i", "<C-O>", "v", "<C-G>"),
"12${c}345", "12${c}345",
"12${s}3${c}${se}45", "12${s}3${c}${se}45",
VimStateMachine.Mode.INSERT_SELECT, Mode.SELECT(SelectionType.CHARACTER_WISE, ReturnTo.INSERT),
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -103,8 +99,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "gh"), listOf("i", "<C-O>", "gh"),
"12${c}345", "12${c}345",
"12${s}3${c}${se}45", "12${s}3${c}${se}45",
VimStateMachine.Mode.INSERT_SELECT, Mode.SELECT(SelectionType.CHARACTER_WISE, ReturnTo.INSERT),
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -116,8 +111,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "gh", "<esc>"), listOf("i", "<C-O>", "gh", "<esc>"),
"12${c}345", "12${c}345",
"123${c}45", "123${c}45",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -130,8 +124,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "gh", "d"), listOf("i", "<C-O>", "gh", "d"),
"12${c}345", "12${c}345",
"12d${c}45", "12d${c}45",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -142,32 +135,31 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "def", "<C-O>", "d2h", "x"), listOf("i", "def", "<C-O>", "d2h", "x"),
"abc$c.\n", "abc$c.\n",
"abcdx.\n", "abcdx.\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
// VIM-321 |d| |count| // VIM-321 |d| |count|
@Test @Test
fun testDeleteEmptyRange() { fun testDeleteEmptyRange() {
doTest("d0", "${c}hello\n", "hello\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("d0", "${c}hello\n", "hello\n", Mode.NORMAL())
} }
// VIM-157 |~| // VIM-157 |~|
@Test @Test
fun testToggleCharCase() { fun testToggleCharCase() {
doTest("~~", "${c}hello world\n", "HEllo world\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("~~", "${c}hello world\n", "HEllo world\n", Mode.NORMAL())
} }
// VIM-157 |~| // VIM-157 |~|
@Test @Test
fun testToggleCharCaseLineEnd() { fun testToggleCharCaseLineEnd() {
doTest("~~", "hello wor${c}ld\n", "hello worLD\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("~~", "hello wor${c}ld\n", "hello worLD\n", Mode.NORMAL())
} }
@Test @Test
fun testToggleCaseMotion() { fun testToggleCaseMotion() {
doTest("g~w", "${c}FooBar Baz\n", "fOObAR Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("g~w", "${c}FooBar Baz\n", "fOObAR Baz\n", Mode.NORMAL())
} }
@Test @Test
@ -176,14 +168,13 @@ class ChangeActionTest : VimTestCase() {
"gUw", "gUw",
"${c}FooBar Baz\n", "${c}FooBar Baz\n",
"FOOBAR Baz\n", "FOOBAR Baz\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@Test @Test
fun testChangeLowerCase() { fun testChangeLowerCase() {
doTest("guw", "${c}FooBar Baz\n", "foobar Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("guw", "${c}FooBar Baz\n", "foobar Baz\n", Mode.NORMAL())
} }
@Test @Test
@ -192,8 +183,7 @@ class ChangeActionTest : VimTestCase() {
"ve~", "ve~",
"${c}FooBar Baz\n", "${c}FooBar Baz\n",
"fOObAR Baz\n", "fOObAR Baz\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -203,8 +193,7 @@ class ChangeActionTest : VimTestCase() {
"veU", "veU",
"${c}FooBar Baz\n", "${c}FooBar Baz\n",
"FOOBAR Baz\n", "FOOBAR Baz\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -214,8 +203,7 @@ class ChangeActionTest : VimTestCase() {
"veu", "veu",
"${c}FooBar Baz\n", "${c}FooBar Baz\n",
"foobar Baz\n", "foobar Baz\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -236,8 +224,7 @@ class ChangeActionTest : VimTestCase() {
four four
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -256,8 +243,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
assertOffset(4) assertOffset(4)
} }
@ -277,8 +263,7 @@ class ChangeActionTest : VimTestCase() {
three three
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -299,8 +284,7 @@ class ChangeActionTest : VimTestCase() {
three three
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -315,8 +299,7 @@ class ChangeActionTest : VimTestCase() {
"""one """one
three three
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
assertOffset(3) assertOffset(3)
} }
@ -332,8 +315,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(), """.trimIndent(),
"one four\n", "one four\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -344,8 +326,7 @@ class ChangeActionTest : VimTestCase() {
"d2w", "d2w",
"on${c}e two three\n", "on${c}e two three\n",
"on${c}three\n", "on${c}three\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -360,8 +341,7 @@ class ChangeActionTest : VimTestCase() {
"""foo """foo
, baz , baz
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -380,8 +360,7 @@ class ChangeActionTest : VimTestCase() {
baz baz
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -400,8 +379,7 @@ class ChangeActionTest : VimTestCase() {
bar bar
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
assertOffset(1) assertOffset(1)
} }
@ -417,8 +395,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(), """.trimIndent(),
"two\n", "two\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -430,8 +407,7 @@ class ChangeActionTest : VimTestCase() {
listOf("A", ", ", "<C-R>", "a", "!"), listOf("A", ", ", "<C-R>", "a", "!"),
"${c}Hello\n", "${c}Hello\n",
"Hello, World!\n", "Hello, World!\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -442,8 +418,7 @@ class ChangeActionTest : VimTestCase() {
listOf("O", "bar"), listOf("O", "bar"),
"fo${c}o\n", "fo${c}o\n",
"bar\nfoo\n", "bar\nfoo\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -454,8 +429,7 @@ class ChangeActionTest : VimTestCase() {
listOf("v", "k\$d"), listOf("v", "k\$d"),
"foo\n${c}bar\n", "foo\n${c}bar\n",
"fooar\n", "fooar\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -478,8 +452,7 @@ class ChangeActionTest : VimTestCase() {
quux quux
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -501,8 +474,7 @@ class ChangeActionTest : VimTestCase() {
quux quux
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -518,8 +490,7 @@ quux
""" a 1 b 2 c 3 """ a 1 b 2 c 3
quux quux
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -535,8 +506,7 @@ quux
""" a 1 b 2 c 3 """ a 1 b 2 c 3
quux quux
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -551,8 +521,7 @@ quux
bar bar
""".dotToSpace().trimIndent(), """.dotToSpace().trimIndent(),
"foo bar", "foo bar",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -565,8 +534,7 @@ quux
bar bar
""".dotToSpace().trimIndent(), """.dotToSpace().trimIndent(),
"foo bar", "foo bar",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -582,8 +550,7 @@ quux
""" a 1 b 2 c 3 """ a 1 b 2 c 3
quux quux
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -599,8 +566,7 @@ quux
""" a 1 b 2 c 3 """ a 1 b 2 c 3
quux quux
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -610,8 +576,7 @@ quux
listOf("<C-V>", "x"), listOf("<C-V>", "x"),
"fo${c}o\n", "fo${c}o\n",
"fo\n", "fo\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -624,8 +589,7 @@ quux
listOf("<C-V>", "j", "x"), listOf("<C-V>", "j", "x"),
"\n\n", "\n\n",
"\n\n", "\n\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -646,8 +610,7 @@ quux
br br
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -669,8 +632,7 @@ quux
br br
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -697,20 +659,20 @@ quux
// |r| // |r|
@Test @Test
fun testReplaceOneChar() { fun testReplaceOneChar() {
doTest("rx", "b${c}ar\n", "b${c}xr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("rx", "b${c}ar\n", "b${c}xr\n", Mode.NORMAL())
} }
// |r| // |r|
@VimBehaviorDiffers(originalVimAfter = "foXX${c}Xr\n") @VimBehaviorDiffers(originalVimAfter = "foXX${c}Xr\n")
@Test @Test
fun testReplaceMultipleCharsWithCount() { fun testReplaceMultipleCharsWithCount() {
doTest("3rX", "fo${c}obar\n", "fo${c}XXXr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("3rX", "fo${c}obar\n", "fo${c}XXXr\n", Mode.NORMAL())
} }
// |r| // |r|
@Test @Test
fun testReplaceMultipleCharsWithCountPastEndOfLine() { fun testReplaceMultipleCharsWithCountPastEndOfLine() {
doTest("6rX", "fo${c}obar\n", "fo${c}obar\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("6rX", "fo${c}obar\n", "fo${c}obar\n", Mode.NORMAL())
} }
// |r| // |r|
@ -729,8 +691,7 @@ quux
ZZZZZz ZZZZZz
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -746,8 +707,7 @@ foobaz
bar bar
foobaz foobaz
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -764,15 +724,14 @@ foobaz
r r
foobaz foobaz
""", """,
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
// |s| // |s|
@Test @Test
fun testReplaceOneCharWithText() { fun testReplaceOneCharWithText() {
doTest("sxy<Esc>", "b${c}ar\n", "bx${c}yr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("sxy<Esc>", "b${c}ar\n", "bx${c}yr\n", Mode.NORMAL())
} }
// |s| // |s|
@ -782,8 +741,7 @@ foobaz
"3sxy<Esc>", "3sxy<Esc>",
"fo${c}obar\n", "fo${c}obar\n",
"fox${c}yr\n", "fox${c}yr\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -802,15 +760,14 @@ foobaz
biff biff
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
// |R| // |R|
@Test @Test
fun testReplaceMode() { fun testReplaceMode() {
doTest("Rbaz<Esc>", "foo${c}bar\n", "fooba${c}z\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("Rbaz<Esc>", "foo${c}bar\n", "fooba${c}z\n", Mode.NORMAL())
} }
// |R| |i_<Insert>| // |R| |i_<Insert>|
@ -821,8 +778,7 @@ foobaz
"RXXX<Ins>YYY<Ins>ZZZ<Esc>", "RXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n", "aaa${c}bbbcccddd\n",
"aaaXXXYYYZZ${c}Zddd\n", "aaaXXXYYYZZ${c}Zddd\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -834,8 +790,7 @@ foobaz
"iXXX<Ins>YYY<Ins>ZZZ<Esc>", "iXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n", "aaa${c}bbbcccddd\n",
"aaaXXXYYYZZ${c}Zcccddd\n", "aaaXXXYYYZZ${c}Zcccddd\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -855,8 +810,7 @@ foobaz
fo${c}o quux fo${c}o quux
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1074,8 +1028,7 @@ and some text after""",
"fXcfYPATATA<Esc>fX.;.", "fXcfYPATATA<Esc>fX.;.",
"${c}aaaaXBBBBYaaaaaaaXBBBBYaaaaaaXBBBBYaaaaaaaa\n", "${c}aaaaXBBBBYaaaaaaaXBBBBYaaaaaaXBBBBYaaaaaaaa\n",
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n", "aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1083,10 +1036,10 @@ and some text after""",
fun testRepeatReplace() { fun testRepeatReplace() {
configureByText("${c}foobarbaz spam\n") configureByText("${c}foobarbaz spam\n")
typeText(injector.parser.parseKeys("R")) typeText(injector.parser.parseKeys("R"))
assertMode(VimStateMachine.Mode.REPLACE) assertMode(Mode.REPLACE)
typeText(injector.parser.parseKeys("FOO" + "<Esc>" + "l" + "2.")) typeText(injector.parser.parseKeys("FOO" + "<Esc>" + "l" + "2."))
assertState("FOOFOOFO${c}O spam\n") assertState("FOOFOOFO${c}O spam\n")
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
@Test @Test
@ -1101,8 +1054,7 @@ and some text after""",
psum dolor sit amet psum dolor sit amet
${c}Lorem Ipsumm dolor sit amet ${c}Lorem Ipsumm dolor sit amet
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1118,8 +1070,7 @@ and some text after""",
ipsum dolor sit amet ipsum dolor sit amet
${c}Lorem Ipsumm dolor sit amet ${c}Lorem Ipsumm dolor sit amet
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1135,8 +1086,7 @@ and some text after""",
ipsum dolor sit amet ipsum dolor sit amet
${c}Lorem Ipsumm dolor sit amet ${c}Lorem Ipsumm dolor sit amet
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1152,8 +1102,7 @@ and some text after""",
ipsum dolor sit amet ipsum dolor sit amet
${c}Lorem Ipsumm dolor sit amet ${c}Lorem Ipsumm dolor sit amet
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1169,8 +1118,7 @@ and some text after""",
${c}Lorem Ipsumm dolor sit amet ${c}Lorem Ipsumm dolor sit amet
psum dolor sit amet psum dolor sit amet
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1186,8 +1134,7 @@ and some text after""",
${c}Lorem Ipsumm dolor sit amet ${c}Lorem Ipsumm dolor sit amet
ipsum dolor sit amet ipsum dolor sit amet
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1206,8 +1153,7 @@ and some text after""",
${c}lorem ipsum dolor sit amet ${c}lorem ipsum dolor sit amet
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1227,8 +1173,7 @@ and some text after""",
gaganis ${c}gaganis gaganis gaganis ${c}gaganis gaganis
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1245,8 +1190,7 @@ and some text after""",
line 1 line 1
${c}line 3 ${c}line 3
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action package org.jetbrains.plugins.ideavim.action
import com.google.common.collect.Lists import com.google.common.collect.Lists
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.TestOptionConstants import org.jetbrains.plugins.ideavim.TestOptionConstants
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.jetbrains.plugins.ideavim.impl.OptionTest import org.jetbrains.plugins.ideavim.impl.OptionTest
@ -18,27 +18,27 @@ import org.junit.jupiter.api.Test
class ChangeNumberActionTest : VimTestCase() { class ChangeNumberActionTest : VimTestCase() {
@Test @Test
fun testIncrementDecimalZero() { fun testIncrementDecimalZero() {
doTest("<C-A>", "0", "1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "0", "1", Mode.NORMAL())
} }
@Test @Test
fun testIncrementHexZero() { fun testIncrementHexZero() {
doTest("<C-A>", "0x0", "0x1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "0x0", "0x1", Mode.NORMAL())
} }
@Test @Test
fun testDecrementZero() { fun testDecrementZero() {
doTest("<C-X>", "0", "-1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-X>", "0", "-1", Mode.NORMAL())
} }
@Test @Test
fun testIncrementDecimal() { fun testIncrementDecimal() {
doTest("<C-A>", "199", "200", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "199", "200", Mode.NORMAL())
} }
@Test @Test
fun testDecrementDecimal() { fun testDecrementDecimal() {
doTest("<C-X>", "1000", "999", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-X>", "1000", "999", Mode.NORMAL())
} }
@Test @Test
@ -47,8 +47,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
"0477", "0477",
"0500", "0500",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -58,29 +57,28 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"),
"010", "010",
"007", "007",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@Test @Test
fun testIncrementHex() { fun testIncrementHex() {
doTest("<C-A>", "0xff", "0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "0xff", "0x100", Mode.NORMAL())
} }
@Test @Test
fun testDecrementHex() { fun testDecrementHex() {
doTest("<C-X>", "0xa100", "0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-X>", "0xa100", "0xa0ff", Mode.NORMAL())
} }
@Test @Test
fun testIncrementNegativeDecimal() { fun testIncrementNegativeDecimal() {
doTest("<C-A>", "-199", "-198", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "-199", "-198", Mode.NORMAL())
} }
@Test @Test
fun testDecrementNegativeDecimal() { fun testDecrementNegativeDecimal() {
doTest("<C-X>", "-1000", "-1001", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-X>", "-1000", "-1001", Mode.NORMAL())
} }
@Test @Test
@ -90,8 +88,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
"-0477", "-0477",
"-0500", "-0500",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -102,34 +99,33 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"),
"-010", "-010",
"-007", "-007",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@Test @Test
fun testIncrementNegativeHex() { fun testIncrementNegativeHex() {
doTest("<C-A>", "-0xff", "-0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "-0xff", "-0x100", Mode.NORMAL())
} }
@Test @Test
fun testDecrementNegativeHex() { fun testDecrementNegativeHex() {
doTest("<C-X>", "-0xa100", "-0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-X>", "-0xa100", "-0xa0ff", Mode.NORMAL())
} }
@Test @Test
fun testIncrementWithCount() { fun testIncrementWithCount() {
doTest("123<C-A>", "456", "579", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("123<C-A>", "456", "579", Mode.NORMAL())
} }
@Test @Test
fun testDecrementWithCount() { fun testDecrementWithCount() {
doTest("200<C-X>", "100", "-100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("200<C-X>", "100", "-100", Mode.NORMAL())
} }
@Test @Test
fun testIncrementAlphaWithoutNumberFormatAlpha() { fun testIncrementAlphaWithoutNumberFormatAlpha() {
doTest("<C-A>", "foo", "foo", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "foo", "foo", Mode.NORMAL())
} }
@Test @Test
@ -138,8 +134,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
"foo", "foo",
"goo", "goo",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -149,8 +144,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
"zzz", "zzz",
"zzz", "zzz",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -160,8 +154,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
"0<caret>x1", "0<caret>x1",
"0y1", "0y1",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -171,8 +164,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"), Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"),
"0<caret>x1", "0<caret>x1",
"0x2", "0x2",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -182,8 +174,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
"0x42", "0x42",
"1x42", "1x42",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -193,8 +184,7 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"),
"077", "077",
"078", "078",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -204,19 +194,18 @@ class ChangeNumberActionTest : VimTestCase() {
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"),
"-077", "-077",
"-076", "-076",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@Test @Test
fun testIncrementHexPreservesCaseOfX() { fun testIncrementHexPreservesCaseOfX() {
doTest("<C-A>", "0X88", "0X89", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "0X88", "0X89", Mode.NORMAL())
} }
@Test @Test
fun testIncrementHexTakesCaseFromLastLetter() { fun testIncrementHexTakesCaseFromLastLetter() {
doTest("<C-A>", "0xaB0", "0xAB1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "0xaB0", "0xAB1", Mode.NORMAL())
} }
@Test @Test
@ -225,8 +214,7 @@ class ChangeNumberActionTest : VimTestCase() {
"<C-A>", "<C-A>",
"foo ->* bar 123\n", "foo ->* bar 123\n",
"foo ->* bar 12<caret>4\n", "foo ->* bar 12<caret>4\n",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -10,7 +10,7 @@ package org.jetbrains.plugins.ideavim.action
import com.intellij.idea.TestFor import com.intellij.idea.TestFor
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.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -227,7 +227,7 @@ class CopyActionTest : VimTestCase() {
""".trimIndent(), """.trimIndent(),
) )
assertOffset(0) assertOffset(0)
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
assertSelection(null) assertSelection(null)
} }

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action package org.jetbrains.plugins.ideavim.action
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -151,7 +151,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.INSERT) assertMode(Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -173,7 +173,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.INSERT) assertMode(Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -195,7 +195,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.INSERT) assertMode(Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -217,7 +217,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.INSERT) assertMode(Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -239,7 +239,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.INSERT) assertMode(Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -259,7 +259,7 @@ class GuardedBlocksTest : VimTestCase() {
$c $c
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.INSERT) assertMode(Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -278,7 +278,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -299,7 +299,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -320,7 +320,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.INSERT) assertMode(Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS) @TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@ -340,6 +340,6 @@ class GuardedBlocksTest : VimTestCase() {
1234567890 1234567890
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
} }

View File

@ -10,7 +10,7 @@ package org.jetbrains.plugins.ideavim.action
import com.google.common.collect.Lists import com.google.common.collect.Lists
import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.handler.enableOctopus import com.maddyhome.idea.vim.handler.enableOctopus
import com.maddyhome.idea.vim.newapi.IjVimEditor import com.maddyhome.idea.vim.newapi.IjVimEditor
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
@ -293,8 +293,7 @@ class MarkTest : VimTestCase() {
four five four five
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }

View File

@ -9,7 +9,8 @@ package org.jetbrains.plugins.ideavim.action
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.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.helper.StringHelper.parseKeys import com.maddyhome.idea.vim.helper.StringHelper.parseKeys
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
@ -24,7 +25,7 @@ class MotionActionTest : VimTestCase() {
@Test @Test
fun testDoubleToggleVisual() { fun testDoubleToggleVisual() {
val contents = "one tw${c}o\n" val contents = "one tw${c}o\n"
doTest("vv", contents, contents, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("vv", contents, contents, Mode.NORMAL())
} }
// VIM-198 |v_iw| // VIM-198 |v_iw|
@ -35,8 +36,7 @@ class MotionActionTest : VimTestCase() {
"viw", "viw",
fileContents, fileContents,
"one ${s}two${se}\n", "one ${s}two${se}\n",
VimStateMachine.Mode.VISUAL, Mode.VISUAL(SelectionType.CHARACTER_WISE),
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -45,7 +45,7 @@ class MotionActionTest : VimTestCase() {
fun testVisualMotionInnerBigWord() { fun testVisualMotionInnerBigWord() {
val fileContents = "one tw${c}o.three four\n" val fileContents = "one tw${c}o.three four\n"
val fileContentsAfter = "one ${s}two.thre${c}e$se four\n" val fileContentsAfter = "one ${s}two.thre${c}e$se four\n"
doTest("viW", fileContents, fileContentsAfter, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER) doTest("viW", fileContents, fileContentsAfter, Mode.VISUAL(SelectionType.CHARACTER_WISE))
assertSelection("two.three") assertSelection("two.three")
} }
@ -56,7 +56,7 @@ class MotionActionTest : VimTestCase() {
three three
""".trimIndent() """.trimIndent()
doTest(listOf("f", "<Esc>", "<Esc>"), content, content, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(listOf("f", "<Esc>", "<Esc>"), content, content, Mode.NORMAL())
assertPluginError(true) assertPluginError(true)
assertOffset(2) assertOffset(2)
} }
@ -68,7 +68,7 @@ class MotionActionTest : VimTestCase() {
three three
""".trimIndent() """.trimIndent()
doTest(listOf("12", "<Esc>"), content, content, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(listOf("12", "<Esc>"), content, content, Mode.NORMAL())
assertPluginError(false) assertPluginError(false)
val vimCommandState = fixture.editor.vimStateMachine val vimCommandState = fixture.editor.vimStateMachine
kotlin.test.assertNotNull(vimCommandState) kotlin.test.assertNotNull(vimCommandState)
@ -80,7 +80,7 @@ class MotionActionTest : VimTestCase() {
fun testLeftRightMove() { fun testLeftRightMove() {
val before = "on${c}e two three four five six seven\n" val before = "on${c}e two three four five six seven\n"
val after = "one two three ${c}four five six seven\n" val after = "one two three ${c}four five six seven\n"
doTest(listOf("14l", "2h"), before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(listOf("14l", "2h"), before, after, Mode.NORMAL())
} }
// |j| |k| // |j| |k|
@ -100,7 +100,7 @@ class MotionActionTest : VimTestCase() {
four four
""".trimIndent() """.trimIndent()
doTest(listOf("2j", "k"), before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(listOf("2j", "k"), before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR) @TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
@ -115,7 +115,7 @@ class MotionActionTest : VimTestCase() {
fun testForwardToTab() { fun testForwardToTab() {
val before = "on${c}e two\tthree\nfour\n" val before = "on${c}e two\tthree\nfour\n"
val after = "one two${c}\tthree\nfour\n" val after = "one two${c}\tthree\nfour\n"
doTest(listOf("f<Tab>"), before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(listOf("f<Tab>"), before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR) @TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
@ -123,7 +123,7 @@ class MotionActionTest : VimTestCase() {
fun testIllegalCharArgument() { fun testIllegalCharArgument() {
typeTextInFile(injector.parser.parseKeys("f<Insert>"), "on${c}e two three four five six seven\n") typeTextInFile(injector.parser.parseKeys("f<Insert>"), "on${c}e two three four five six seven\n")
assertOffset(2) assertOffset(2)
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
// |F| |i_CTRL-K| // |F| |i_CTRL-K|
@ -132,7 +132,7 @@ class MotionActionTest : VimTestCase() {
val before = "Hallo, Öster${c}reich!\n" val before = "Hallo, Öster${c}reich!\n"
val after = "Hallo, ${c}Österreich!\n" val after = "Hallo, ${c}Österreich!\n"
val keys = listOf("F<C-K>O:") val keys = listOf("F<C-K>O:")
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-771 |t| |;| // VIM-771 |t| |;|
@ -141,7 +141,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("t:;") val keys = listOf("t:;")
val before = "$c 1:a 2:b 3:c \n" val before = "$c 1:a 2:b 3:c \n"
val after = " 1:a ${c}2:b 3:c \n" val after = " 1:a ${c}2:b 3:c \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-771 |t| |;| // VIM-771 |t| |;|
@ -150,7 +150,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("t:;") val keys = listOf("t:;")
val before = "$c 1:a 2:b 3:c \n" val before = "$c 1:a 2:b 3:c \n"
val after = " 1:a ${c}2:b 3:c \n" val after = " 1:a ${c}2:b 3:c \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-771 |t| |;| // VIM-771 |t| |;|
@ -159,7 +159,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("t:2;") val keys = listOf("t:2;")
val before = "$c 1:a 2:b 3:c \n" val before = "$c 1:a 2:b 3:c \n"
val after = " 1:a ${c}2:b 3:c \n" val after = " 1:a ${c}2:b 3:c \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-771 |t| |;| // VIM-771 |t| |;|
@ -168,7 +168,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("t:3;") val keys = listOf("t:3;")
val before = "$c 1:a 2:b 3:c \n" val before = "$c 1:a 2:b 3:c \n"
val after = " 1:a 2:b ${c}3:c \n" val after = " 1:a 2:b ${c}3:c \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-771 |t| |,| // VIM-771 |t| |,|
@ -177,7 +177,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("t:,,") val keys = listOf("t:,,")
val before = " 1:a 2:b$c 3:c \n" val before = " 1:a 2:b$c 3:c \n"
val after = " 1:${c}a 2:b 3:c \n" val after = " 1:${c}a 2:b 3:c \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-771 |t| |,| // VIM-771 |t| |,|
@ -186,7 +186,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("t:,2,") val keys = listOf("t:,2,")
val before = " 1:a 2:b$c 3:c \n" val before = " 1:a 2:b$c 3:c \n"
val after = " 1:${c}a 2:b 3:c \n" val after = " 1:${c}a 2:b 3:c \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-771 |t| |,| // VIM-771 |t| |,|
@ -195,7 +195,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("t:,3,") val keys = listOf("t:,3,")
val before = " 0:_ 1:a 2:b$c 3:c \n" val before = " 0:_ 1:a 2:b$c 3:c \n"
val after = " 0:${c}_ 1:a 2:b 3:c \n" val after = " 0:${c}_ 1:a 2:b 3:c \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-314 |d| |v_iB| // VIM-314 |d| |v_iB|
@ -204,7 +204,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di{") val keys = listOf("di{")
val before = "{foo, b${c}ar, baz}\n" val before = "{foo, b${c}ar, baz}\n"
val after = "{}\n" val after = "{}\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-314 |d| |v_iB| // VIM-314 |d| |v_iB|
@ -213,7 +213,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di{") val keys = listOf("di{")
val before = "{foo, ${c}\"bar\", baz}\n" val before = "{foo, ${c}\"bar\", baz}\n"
val after = "{}\n" val after = "{}\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_aB| // |d| |v_aB|
@ -222,7 +222,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da{") val keys = listOf("da{")
val before = "x = {foo, b${c}ar, baz};\n" val before = "x = {foo, b${c}ar, baz};\n"
val after = "x = ;\n" val after = "x = ;\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-261 |c| |v_iB| // VIM-261 |c| |v_iB|
@ -253,7 +253,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("daw") val keys = listOf("daw")
val before = "one t${c}wo three\n" val before = "one t${c}wo three\n"
val after = "one three\n" val after = "one three\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_aW| // |d| |v_aW|
@ -262,7 +262,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("daW") val keys = listOf("daW")
val before = "one \"t${c}wo\" three\n" val before = "one \"t${c}wo\" three\n"
val after = "one three\n" val after = "one three\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_is| // |d| |v_is|
@ -271,7 +271,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("dis") val keys = listOf("dis")
val before = "Hello World! How a${c}re you? Bye.\n" val before = "Hello World! How a${c}re you? Bye.\n"
val after = "Hello World! Bye.\n" val after = "Hello World! Bye.\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_as| // |d| |v_as|
@ -280,7 +280,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("das") val keys = listOf("das")
val before = "Hello World! How a${c}re you? Bye.\n" val before = "Hello World! How a${c}re you? Bye.\n"
val after = "Hello World! Bye.\n" val after = "Hello World! Bye.\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |v_as| // |v_as|
@ -299,7 +299,7 @@ class MotionActionTest : VimTestCase() {
P$c. P$c.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_ip| // |d| |v_ip|
@ -322,7 +322,7 @@ class MotionActionTest : VimTestCase() {
Bye. Bye.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_ap| // |d| |v_ap|
@ -344,7 +344,7 @@ class MotionActionTest : VimTestCase() {
Bye. Bye.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_a]| // |d| |v_a]|
@ -358,7 +358,7 @@ class MotionActionTest : VimTestCase() {
]; ];
""" """
val after = "foo = ;\n" val after = "foo = ;\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_i]| // |d| |v_i]|
@ -367,7 +367,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di]") val keys = listOf("di]")
val before = "foo = [one, t${c}wo];\n" val before = "foo = [one, t${c}wo];\n"
val after = "foo = [];\n" val after = "foo = [];\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-1287 |d| |v_i(| // VIM-1287 |d| |v_i(|
@ -376,7 +376,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di(") val keys = listOf("di(")
val before = "(text \"with quotes(and ${c}braces)\")" val before = "(text \"with quotes(and ${c}braces)\")"
val after = "(text \"with quotes()\")" val after = "(text \"with quotes()\")"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-1287 |d| |v_i{| // VIM-1287 |d| |v_i{|
@ -385,7 +385,7 @@ class MotionActionTest : VimTestCase() {
val before = "{\"{foo, ${c}bar\", baz}}" val before = "{\"{foo, ${c}bar\", baz}}"
val keys = listOf("di{") val keys = listOf("di{")
val after = "{\"{foo, ${c}bar\", baz}}" val after = "{\"{foo, ${c}bar\", baz}}"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-1287 |d| |v_i{| // VIM-1287 |d| |v_i{|
@ -394,7 +394,7 @@ class MotionActionTest : VimTestCase() {
val before = "a{\"{foo}, ${c}bar\", baz}b}" val before = "a{\"{foo}, ${c}bar\", baz}b}"
val keys = listOf("di{") val keys = listOf("di{")
val after = "a{$c}b}" val after = "a{$c}b}"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-1008 |c| |v_i{| // VIM-1008 |c| |v_i{|
@ -403,7 +403,7 @@ class MotionActionTest : VimTestCase() {
val before = "\"{do${c}esn't work}\"" val before = "\"{do${c}esn't work}\""
val keys = listOf("ci{") val keys = listOf("ci{")
val after = "\"{$c}\"" val after = "\"{$c}\""
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
// VIM-1008 |c| |v_i{| // VIM-1008 |c| |v_i{|
@ -412,7 +412,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("ci{") val keys = listOf("ci{")
val before = "'{does n${c}ot work}'" val before = "'{does n${c}ot work}'"
val after = "'{$c}'" val after = "'{$c}'"
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
// VIM-1008 |c| |v_i{| // VIM-1008 |c| |v_i{|
@ -421,7 +421,7 @@ class MotionActionTest : VimTestCase() {
val before = "<p class=\"{{ \$ctrl.so${c}meClassName }}\"></p>" val before = "<p class=\"{{ \$ctrl.so${c}meClassName }}\"></p>"
val keys = listOf("ci{") val keys = listOf("ci{")
val after = "<p class=\"{{$c}}\"></p>" val after = "<p class=\"{{$c}}\"></p>"
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
// |d| |v_i>| // |d| |v_i>|
@ -430,7 +430,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di>") val keys = listOf("di>")
val before = "Foo<Foo, B${c}ar> bar\n" val before = "Foo<Foo, B${c}ar> bar\n"
val after = "Foo<> bar\n" val after = "Foo<> bar\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |d| |v_a>| // |d| |v_a>|
@ -439,7 +439,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da>") val keys = listOf("da>")
val before = "Foo<Foo, B${c}ar> bar\n" val before = "Foo<Foo, B${c}ar> bar\n"
val after = "Foo bar\n" val after = "Foo bar\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_i"| // VIM-132 |d| |v_i"|
@ -448,7 +448,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "foo = \"bar b${c}az\";\n" val before = "foo = \"bar b${c}az\";\n"
val after = "foo = \"\";\n" val after = "foo = \"\";\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_a"| // VIM-132 |d| |v_a"|
@ -458,7 +458,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da\"") val keys = listOf("da\"")
val before = "foo = \"bar b${c}az\";\n" val before = "foo = \"bar b${c}az\";\n"
val after = "foo = ;\n" val after = "foo = ;\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_i"| // VIM-132 |d| |v_i"|
@ -467,7 +467,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "foo = [\"one\", ${c}\"two\", \"three\"];\n" val before = "foo = [\"one\", ${c}\"two\", \"three\"];\n"
val after = "foo = [\"one\", \"\", \"three\"];\n" val after = "foo = [\"one\", \"\", \"three\"];\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_i"| // VIM-132 |d| |v_i"|
@ -476,7 +476,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "foo = [\"one\", \"two${c}\", \"three\"];\n" val before = "foo = [\"one\", \"two${c}\", \"three\"];\n"
val after = "foo = [\"one\", \"\", \"three\"];\n" val after = "foo = [\"one\", \"\", \"three\"];\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_i"| // VIM-132 |d| |v_i"|
@ -485,7 +485,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "foo = \"fo\\\"o b${c}ar\";\n" val before = "foo = \"fo\\\"o b${c}ar\";\n"
val after = "foo = \"\";\n" val after = "foo = \"\";\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_i"| // VIM-132 |d| |v_i"|
@ -494,7 +494,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "f${c}oo = [\"one\", \"two\", \"three\"];\n" val before = "f${c}oo = [\"one\", \"two\", \"three\"];\n"
val after = "foo = [\"\", \"two\", \"three\"];\n" val after = "foo = [\"\", \"two\", \"three\"];\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -502,7 +502,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "abc\"def${c}\"gh\"i" val before = "abc\"def${c}\"gh\"i"
val after = "abc\"\"gh\"i" val after = "abc\"\"gh\"i"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -510,7 +510,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "abc\"def\"g${c}h\"ijk\"l" val before = "abc\"def\"g${c}h\"ijk\"l"
val after = "abc\"def\"\"ijk\"l" val after = "abc\"def\"\"ijk\"l"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -518,7 +518,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "abcdef\"gh\"ij${c}\"kl" val before = "abcdef\"gh\"ij${c}\"kl"
val after = "abcdef\"gh\"ij\"kl" val after = "abcdef\"gh\"ij\"kl"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -526,7 +526,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"") val keys = listOf("di\"")
val before = "abc\"def\"gh\"ij${c}\"kl" val before = "abc\"def\"gh\"ij${c}\"kl"
val after = "abc\"def\"gh\"\"kl" val after = "abc\"def\"gh\"\"kl"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |v_i"| // VIM-132 |v_i"|
@ -535,7 +535,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("vi\"") val keys = listOf("vi\"")
val before = "foo = [\"o${c}ne\", \"two\"];\n" val before = "foo = [\"o${c}ne\", \"two\"];\n"
val after = "foo = [\"${s}on${c}e${se}\", \"two\"];\n" val after = "foo = [\"${s}on${c}e${se}\", \"two\"];\n"
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER) doTest(keys, before, after, Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
// |c| |v_i"| // |c| |v_i"|
@ -544,7 +544,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("ci\"") val keys = listOf("ci\"")
val before = "foo = \"${c}\";\n" val before = "foo = \"${c}\";\n"
val after = "foo = \"\";\n" val after = "foo = \"\";\n"
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
// VIM-132 |d| |v_i'| // VIM-132 |d| |v_i'|
@ -553,7 +553,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di'") val keys = listOf("di'")
val before = "foo = 'bar b${c}az';\n" val before = "foo = 'bar b${c}az';\n"
val after = "foo = '';\n" val after = "foo = '';\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_i`| // VIM-132 |d| |v_i`|
@ -562,7 +562,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di`") val keys = listOf("di`")
val before = "foo = `bar b${c}az`;\n" val before = "foo = `bar b${c}az`;\n"
val after = "foo = ``;\n" val after = "foo = ``;\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_a'| // VIM-132 |d| |v_a'|
@ -572,7 +572,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da'") val keys = listOf("da'")
val before = "foo = 'bar b${c}az';\n" val before = "foo = 'bar b${c}az';\n"
val after = "foo = ;\n" val after = "foo = ;\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-132 |d| |v_a`| // VIM-132 |d| |v_a`|
@ -582,7 +582,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da`") val keys = listOf("da`")
val before = "foo = `bar b${c}az`;\n" val before = "foo = `bar b${c}az`;\n"
val after = "foo = ;\n" val after = "foo = ;\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-2733 // VIM-2733
@ -599,7 +599,7 @@ class MotionActionTest : VimTestCase() {
print($c) print($c)
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-2733 // VIM-2733
@ -616,7 +616,7 @@ class MotionActionTest : VimTestCase() {
print($c) print($c)
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-2733 // VIM-2733
@ -633,7 +633,7 @@ class MotionActionTest : VimTestCase() {
print($c) print($c)
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-2733 // VIM-2733
@ -650,7 +650,7 @@ class MotionActionTest : VimTestCase() {
print($c) print($c)
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-1427 // VIM-1427
@ -659,7 +659,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("d2at") val keys = listOf("d2at")
val before = "<a><b><c>$c</c></b></a>" val before = "<a><b><c>$c</c></b></a>"
val after = "<a></a>" val after = "<a></a>"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-2113 // VIM-2113
@ -668,7 +668,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("cit") val keys = listOf("cit")
val before = "<a><c>$c</c></a>" val before = "<a><c>$c</c></a>"
val after = "<a><c></c></a>" val after = "<a><c></c></a>"
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
@Test @Test
@ -676,7 +676,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("d/<C-K>O:<CR>") val keys = listOf("d/<C-K>O:<CR>")
val before = "ab${c}cdÖef" val before = "ab${c}cdÖef"
val after = "abÖef" val after = "abÖef"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |[(| // |[(|
@ -948,7 +948,7 @@ two
val keys = listOf("viw", "<Esc>", "0", "viw", "gv", "d") val keys = listOf("viw", "<Esc>", "0", "viw", "gv", "d")
val before = "foo ${c}bar\n" val before = "foo ${c}bar\n"
val after = "foo \n" val after = "foo \n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |CTRL-V| // |CTRL-V|
@ -965,7 +965,7 @@ two
${s}ba${se}r ${s}ba${se}r
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK) doTest(keys, before, after, Mode.VISUAL(SelectionType.BLOCK_WISE))
} }
// |CTRL-V| // |CTRL-V|
@ -982,7 +982,7 @@ two
b${s}ar$se b${s}ar$se
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK) doTest(keys, before, after, Mode.VISUAL(SelectionType.BLOCK_WISE))
} }
// |CTRL-V| // |CTRL-V|
@ -1001,7 +1001,7 @@ two
a${s}b$se a${s}b$se
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK) doTest(keys, before, after, Mode.VISUAL(SelectionType.BLOCK_WISE))
} }
// |v_o| // |v_o|
@ -1010,7 +1010,7 @@ two
val keys = listOf("v", "l", "o", "l", "d") val keys = listOf("v", "l", "o", "l", "d")
val before = "${c}foo\n" val before = "${c}foo\n"
val after = "fo\n" val after = "fo\n"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// VIM-564 |g_| // VIM-564 |g_|
@ -1032,8 +1032,7 @@ two
four four
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1056,8 +1055,7 @@ two
four four
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -1078,7 +1076,7 @@ two
bar bar
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
// |v_>| |gv| // |v_>| |gv|
@ -1103,7 +1101,7 @@ two
""".trimIndent(), """.trimIndent(),
) )
typeText(injector.parser.parseKeys(">")) typeText(injector.parser.parseKeys(">"))
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
assertState( assertState(
""" foo """ foo
bar bar
@ -1118,7 +1116,7 @@ two
""", """,
) )
typeText(injector.parser.parseKeys(">")) typeText(injector.parser.parseKeys(">"))
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
assertState( assertState(
""" foo """ foo
bar bar
@ -1148,7 +1146,7 @@ two
bar bar
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER) doTest(keys, before, after, Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@Test @Test
@ -1163,7 +1161,7 @@ two
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.LINE_WISE))
assertSelection( assertSelection(
""" """
bar bar
@ -1187,7 +1185,7 @@ two
""".trimIndent(), """.trimIndent(),
) )
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.LINE_WISE))
assertSelection( assertSelection(
""" """
bar bar

View File

@ -11,7 +11,7 @@ import com.intellij.idea.TestFor
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import com.maddyhome.idea.vim.newapi.IjVimEditor import com.maddyhome.idea.vim.newapi.IjVimEditor

View File

@ -11,7 +11,7 @@ package org.jetbrains.plugins.ideavim.action
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.command.MappingMode import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.key.MappingOwner import com.maddyhome.idea.vim.key.MappingOwner
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -26,7 +26,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "<C-\\><C-N>" val keys = "<C-\\><C-N>"
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Lorem Ipsum" val after = "Lorem Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -35,7 +35,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>") val keys = listOf("i", "<C-\\><C-N>")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Lorem Ipsum" val after = "Lorem Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -44,7 +44,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>") val keys = listOf("i", "<C-\\><C-N>")
val before = "A Disc${c}overy" val before = "A Disc${c}overy"
val after = "A Dis${c}covery" val after = "A Dis${c}covery"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -53,7 +53,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>", "3l") val keys = listOf("i", "<C-\\><C-N>", "3l")
val before = "${c}Lorem Ipsum" val before = "${c}Lorem Ipsum"
val after = "Lorem Ipsum" val after = "Lorem Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -62,7 +62,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("V", "<C-\\><C-N>") val keys = listOf("V", "<C-\\><C-N>")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Lorem Ipsum" val after = "Lorem Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -71,7 +71,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("gH", "<C-\\><C-N>") val keys = listOf("gH", "<C-\\><C-N>")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Lorem Ipsum" val after = "Lorem Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -80,7 +80,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-\\><C-N>") val keys = listOf("d", "<C-\\><C-N>")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Lorem Ipsum" val after = "Lorem Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -89,7 +89,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "d<Esc>dw" val keys = "d<Esc>dw"
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Ipsum" val after = "Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -98,7 +98,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-\\><C-N>", "dw") val keys = listOf("d", "<C-\\><C-N>", "dw")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Ipsum" val after = "Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -107,7 +107,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<Esc>", "dw") val keys = listOf("d", "<Esc>", "dw")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Ipsum" val after = "Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -117,7 +117,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-[>", "dw") val keys = listOf("d", "<C-[>", "dw")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Ipsum" val after = "Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -136,7 +136,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-D>", "dw") val keys = listOf("d", "<C-D>", "dw")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Ipsum" val after = "Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -145,7 +145,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("c", "<C-\\><C-N>", "another") val keys = listOf("c", "<C-\\><C-N>", "another")
val before = "Lorem Ipsum" val before = "Lorem Ipsum"
val after = "Lnotherorem Ipsum" val after = "Lnotherorem Ipsum"
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
@ -154,7 +154,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "dt<esc>D" val keys = "dt<esc>D"
val before = "A ${c}Discovery" val before = "A ${c}Discovery"
val after = "A " val after = "A "
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection()) kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
} }
} }

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.change package org.jetbrains.plugins.ideavim.action.change
import com.intellij.idea.TestFor import com.intellij.idea.TestFor
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -36,7 +36,7 @@ class RepeatChangeActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -58,7 +58,7 @@ class RepeatChangeActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -80,7 +80,7 @@ class RepeatChangeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@VimBehaviorDiffers(description = "Different caret position") @VimBehaviorDiffers(description = "Different caret position")
@ -103,7 +103,7 @@ class RepeatChangeActionTest : VimTestCase() {
whe${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX whe${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXX by the torrent of a mountain pass. XXXX by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -125,7 +125,7 @@ class RepeatChangeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -147,7 +147,7 @@ class RepeatChangeActionTest : VimTestCase() {
where XXXXXX settled on some sodden sand where XXXXXX settled on some sodden sand
${c}XXXXXXy the torrent of a mountain pass. ${c}XXXXXXy the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -169,7 +169,7 @@ class RepeatChangeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@VimBehaviorDiffers(description = "Wrong caret position") @VimBehaviorDiffers(description = "Wrong caret position")
@ -192,7 +192,7 @@ class RepeatChangeActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@VimBehaviorDiffers(description = "Wrong caret position") @VimBehaviorDiffers(description = "Wrong caret position")
@ -215,7 +215,7 @@ class RepeatChangeActionTest : VimTestCase() {
|Sed in orci mauris. |Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas. |Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@VimBehaviorDiffers(description = "Wrong caret position") @VimBehaviorDiffers(description = "Wrong caret position")
@ -238,7 +238,7 @@ class RepeatChangeActionTest : VimTestCase() {
wherXXXt was settled on some sodden sand wherXXXt was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@VimBehaviorDiffers( @VimBehaviorDiffers(
@ -273,7 +273,7 @@ class RepeatChangeActionTest : VimTestCase() {
XXXXX${c}Xy the torrent of a mountain pass. XXXXX${c}Xy the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR) @TestWithoutNeovim(SkipNeovimReason.UNCLEAR)
@ -296,7 +296,7 @@ class RepeatChangeActionTest : VimTestCase() {
${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -318,7 +318,7 @@ class RepeatChangeActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@VimBehaviorDiffers( @VimBehaviorDiffers(
@ -344,8 +344,7 @@ class RepeatChangeActionTest : VimTestCase() {
One One
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change package org.jetbrains.plugins.ideavim.action.change
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -25,7 +25,7 @@ class UndoActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
val after = before val after = before
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
val editor = fixture.editor val editor = fixture.editor
kotlin.test.assertFalse(editor.caretModel.primaryCaret.hasSelection()) kotlin.test.assertFalse(editor.caretModel.primaryCaret.hasSelection())
} }
@ -42,7 +42,7 @@ class UndoActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
val after = before val after = before
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(hasSelection()) kotlin.test.assertFalse(hasSelection())
} }
@ -65,7 +65,7 @@ class UndoActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(hasSelection()) kotlin.test.assertFalse(hasSelection())
} }
@ -89,7 +89,7 @@ class UndoActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(hasSelection()) kotlin.test.assertFalse(hasSelection())
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.change package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -18,7 +18,7 @@ class ChangeLineActionTest : VimTestCase() {
setupChecks { setupChecks {
this.neoVim.ignoredRegisters = setOf('1', '"') this.neoVim.ignoredRegisters = setOf('1', '"')
} }
doTest("cc", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("cc", "", "", Mode.INSERT)
} }
@Test @Test
@ -26,7 +26,7 @@ class ChangeLineActionTest : VimTestCase() {
setupChecks { setupChecks {
this.neoVim.ignoredRegisters = setOf('1', '"') this.neoVim.ignoredRegisters = setOf('1', '"')
} }
doTest("S", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("S", "", "", Mode.INSERT)
} }
@Test @Test
@ -41,8 +41,7 @@ class ChangeLineActionTest : VimTestCase() {
Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet,
$c $c
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -60,8 +59,7 @@ class ChangeLineActionTest : VimTestCase() {
$c $c
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -77,8 +75,7 @@ class ChangeLineActionTest : VimTestCase() {
Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet,
$c $c
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -96,8 +93,7 @@ class ChangeLineActionTest : VimTestCase() {
$c $c
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -113,8 +109,7 @@ class ChangeLineActionTest : VimTestCase() {
$c $c
consectetur adipiscing elit consectetur adipiscing elit
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -132,8 +127,7 @@ class ChangeLineActionTest : VimTestCase() {
$c $c
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -151,8 +145,7 @@ class ChangeLineActionTest : VimTestCase() {
consectetur adipiscing elit consectetur adipiscing elit
$c $c
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -190,8 +183,7 @@ class ChangeLineActionTest : VimTestCase() {
that priceless mote now dimpling the convex that priceless mote now dimpling the convex
and limpid teardrop on a lighted slide. and limpid teardrop on a lighted slide.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -10,7 +10,7 @@
package org.jetbrains.plugins.ideavim.action.change.change package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -19,13 +19,13 @@ class ChangeMotionActionTest : VimTestCase() {
// VIM-515 |c| |W| // VIM-515 |c| |W|
@Test @Test
fun `test change big word with punctuation and alpha`() { fun `test change big word with punctuation and alpha`() {
doTest("cW", "foo${c}(bar baz\n", "foo baz\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("cW", "foo${c}(bar baz\n", "foo baz\n", Mode.INSERT)
} }
// VIM-300 |c| |w| // VIM-300 |c| |w|
@Test @Test
fun testChangeWordTwoWordsWithoutWhitespace() { fun testChangeWordTwoWordsWithoutWhitespace() {
doTest("cw", "${c}\$value\n", "value\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("cw", "${c}\$value\n", "value\n", Mode.INSERT)
} }
// VIM-296 |cc| // VIM-296 |cc|
@ -35,8 +35,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cc", "cc",
"foo\n" + "${c}bar\n", "foo\n" + "${c}bar\n",
"foo\n${c}" + "\n", "foo\n${c}" + "\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -55,8 +54,7 @@ class ChangeMotionActionTest : VimTestCase() {
....${c} ....${c}
} }
""".trimIndent().dotToSpace(), """.trimIndent().dotToSpace(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -67,8 +65,7 @@ class ChangeMotionActionTest : VimTestCase() {
"ccbaz", "ccbaz",
"${c}foo\n" + "bar\n", "${c}foo\n" + "bar\n",
"baz\n" + "bar\n", "baz\n" + "bar\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -86,8 +83,7 @@ class ChangeMotionActionTest : VimTestCase() {
${c} ${c}
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -97,8 +93,7 @@ class ChangeMotionActionTest : VimTestCase() {
"c_baz", "c_baz",
"${c}foo\n" + "bar\n", "${c}foo\n" + "bar\n",
"baz\n" + "bar\n", "baz\n" + "bar\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -109,8 +104,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cw", "cw",
"on${c}e two three\n", "on${c}e two three\n",
"on${c} two three\n", "on${c} two three\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -121,8 +115,7 @@ class ChangeMotionActionTest : VimTestCase() {
"c2w", "c2w",
"on${c}e two three\n", "on${c}e two three\n",
"on${c} three\n", "on${c} three\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -141,8 +134,7 @@ class ChangeMotionActionTest : VimTestCase() {
} }
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -153,8 +145,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cT(", "cT(",
"if (condition) ${c}{\n" + "}\n", "if (condition) ${c}{\n" + "}\n",
"if ({\n" + "}\n", "if ({\n" + "}\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -167,8 +158,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cFc", "cFc",
"if (condition) {${c}\n" + "}\n", "if (condition) {${c}\n" + "}\n",
"if (\n" + "}\n", "if (\n" + "}\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -179,8 +169,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cw", "cw",
"ab.${c}cd\n", "ab.${c}cd\n",
"ab.${c}\n", "ab.${c}\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -191,19 +180,18 @@ class ChangeMotionActionTest : VimTestCase() {
listOf("c", "iw", "baz"), listOf("c", "iw", "baz"),
"foo bar bo${c}o\n", "foo bar bo${c}o\n",
"foo bar baz\n", "foo bar baz\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
// VIM-421 |c| |w| // VIM-421 |c| |w|
@Test @Test
fun testChangeLastCharInLine() { fun testChangeLastCharInLine() {
doTest("cw", "fo${c}o\n", "fo${c}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("cw", "fo${c}o\n", "fo${c}\n", Mode.INSERT)
} }
@Test @Test
fun testLastSymbolInWord() { fun testLastSymbolInWord() {
doTest("cw", "fo${c}o", "fo${c}", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("cw", "fo${c}o", "fo${c}", Mode.INSERT)
} }
} }

View File

@ -11,7 +11,7 @@
package org.jetbrains.plugins.ideavim.action.change.change package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -35,7 +35,7 @@ class ChangeVisualActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -56,7 +56,7 @@ class ChangeVisualActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
@VimBehaviorDiffers( @VimBehaviorDiffers(
@ -89,7 +89,7 @@ class ChangeVisualActionTest : VimTestCase() {
${c} ${c}
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
@Test @Test
@ -116,7 +116,7 @@ class ChangeVisualActionTest : VimTestCase() {
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
@VimBehaviorDiffers(description = "Wrong caret position") @VimBehaviorDiffers(description = "Wrong caret position")
@ -139,7 +139,7 @@ class ChangeVisualActionTest : VimTestCase() {
wh|Hello wh|Hello
ha|Hello ha|Hello
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -147,7 +147,7 @@ class ChangeVisualActionTest : VimTestCase() {
val keys = "VcHello<esc>" val keys = "VcHello<esc>"
val before = "${c}Lorem Ipsum" val before = "${c}Lorem Ipsum"
val after = "Hello" val after = "Hello"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -156,7 +156,7 @@ class ChangeVisualActionTest : VimTestCase() {
injector.parser.parseKeys("v2lc" + "aaa" + "<ESC>"), injector.parser.parseKeys("v2lc" + "aaa" + "<ESC>"),
"abcd${c}ffffff${c}abcde${c}aaaa\n", "abcd${c}ffffff${c}abcde${c}aaaa\n",
) )
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
assertState("abcdaa${c}afffaa${c}adeaa${c}aa\n") assertState("abcdaa${c}afffaa${c}adeaa${c}aa\n")
} }
@ -178,8 +178,7 @@ class ChangeVisualActionTest : VimTestCase() {
ba_quux_bar ba_quux_bar
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -201,8 +200,7 @@ class ChangeVisualActionTest : VimTestCase() {
ba_quux_bar ba_quux_bar
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -10,7 +10,7 @@
package org.jetbrains.plugins.ideavim.action.change.change package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -35,7 +35,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
${c} ${c}
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
@Test @Test
@ -59,7 +59,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
${c} ${c}
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
@VimBehaviorDiffers( @VimBehaviorDiffers(
@ -93,6 +93,6 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
${c} ${c}
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.change package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -38,6 +38,6 @@ class InsertRegisterTest : VimTestCase() {
all rocks and lavender and tufted grass, all rocks and lavender and tufted grass,
$c $c
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
} }

View File

@ -8,19 +8,19 @@
package org.jetbrains.plugins.ideavim.action.change.change.number package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class ChangeNumberDecActionTest : VimTestCase() { class ChangeNumberDecActionTest : VimTestCase() {
@Test @Test
fun `test decrement hex to negative value`() { fun `test decrement hex to negative value`() {
doTest("<C-X>", "0x0000", "0xffffffffffffffff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-X>", "0x0000", "0xffffffffffffffff", Mode.NORMAL())
} }
@Test @Test
fun `test decrement hex to negative value by 10`() { fun `test decrement hex to negative value by 10`() {
doTest("10<C-X>", "0x0005", "0xfffffffffffffffb", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("10<C-X>", "0x0005", "0xfffffffffffffffb", Mode.NORMAL())
} }
@Test @Test
@ -29,14 +29,13 @@ class ChangeNumberDecActionTest : VimTestCase() {
":set nrformats+=octal<CR><C-X>", ":set nrformats+=octal<CR><C-X>",
"00000", "00000",
"01777777777777777777777", "01777777777777777777777",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@Test @Test
fun `test decrement incorrect octal`() { fun `test decrement incorrect octal`() {
doTest(":set nrformats+=octal<CR><C-X>", "008", "7", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(":set nrformats+=octal<CR><C-X>", "008", "7", Mode.NORMAL())
} }
@Test @Test
@ -45,8 +44,7 @@ class ChangeNumberDecActionTest : VimTestCase() {
":set nrformats+=octal<CR>10<C-X>", ":set nrformats+=octal<CR>10<C-X>",
"00005", "00005",
"01777777777777777777773", "01777777777777777777773",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -17,6 +17,6 @@ class ChangeNumberIncActionTest : VimTestCase() {
@VimBehaviorDiffers(originalVimAfter = "11X0") @VimBehaviorDiffers(originalVimAfter = "11X0")
@Test @Test
fun `test inc fancy number`() { fun `test inc fancy number`() {
doTest("<C-A>", "1${c}0X0", "10X1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("<C-A>", "1${c}0X0", "10X1", Mode.NORMAL())
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -30,8 +30,7 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1 number 1
number 1 number 1
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -49,8 +48,7 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1 number 1
number 1 number 1
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -30,8 +30,7 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 3 number 3
number 4 number 4
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -49,8 +48,7 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 5 number 5
number 7 number 7
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -23,8 +23,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"V<C-X>", "V<C-X>",
"${c}12345", "${c}12345",
"${c}12344", "${c}12344",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -34,8 +33,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"v10w<C-X>", "v10w<C-X>",
"11 <- should not be decremented |${c}11| should not be decremented -> 12", "11 <- should not be decremented |${c}11| should not be decremented -> 12",
"11 <- should not be decremented |${c}10| should not be decremented -> 12", "11 <- should not be decremented |${c}10| should not be decremented -> 12",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -45,8 +43,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"v4l<C-X>", "v4l<C-X>",
"11111${c}33333111111", "11111${c}33333111111",
"11111${c}33332111111", "11111${c}33332111111",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -74,8 +71,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
no dec 1 no dec 1
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -93,8 +89,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
999 999
999 999
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -104,8 +99,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"V<C-X>", "V<C-X>",
"1 should$c not be decremented -> 2", "1 should$c not be decremented -> 2",
"${c}0 should not be decremented -> 2", "${c}0 should not be decremented -> 2",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -23,8 +23,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"V<C-A>", "V<C-A>",
"${c}12345", "${c}12345",
"${c}12346", "${c}12346",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -34,8 +33,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"v10w<C-A>", "v10w<C-A>",
"11 <- should not be incremented |${c}11| should not be incremented -> 12", "11 <- should not be incremented |${c}11| should not be incremented -> 12",
"11 <- should not be incremented |${c}12| should not be incremented -> 12", "11 <- should not be incremented |${c}12| should not be incremented -> 12",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -45,8 +43,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"v4l<C-A>", "v4l<C-A>",
"11111${c}22222111111", "11111${c}22222111111",
"11111${c}22223111111", "11111${c}22223111111",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -74,8 +71,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
no inc 1 no inc 1
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -93,8 +89,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
1000 1000
1000 1000
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -104,8 +99,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"V<C-A>", "V<C-A>",
"1 should$c not be incremented -> 2", "1 should$c not be incremented -> 2",
"${c}2 should not be incremented -> 2", "${c}2 should not be incremented -> 2",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -138,8 +132,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"v$<C-A>", "v$<C-A>",
"1 <- should$c not be incremented 2", "1 <- should$c not be incremented 2",
"1 <- should$c not be incremented 3", "1 <- should$c not be incremented 3",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -153,8 +146,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"""1 <- should$c not be incremented 3 """1 <- should$c not be incremented 3
|2 should not be incremented -> 2 |2 should not be incremented -> 2
""".trimMargin(), """.trimMargin(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -170,8 +162,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|2 should not be incremented -> 2 |2 should not be incremented -> 2
|2 should not be incremented -> 2 |2 should not be incremented -> 2
""".trimMargin(), """.trimMargin(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -189,8 +180,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|1 <- should not be incremented -> 2 |1 <- should not be incremented -> 2
|1 <- should not be incremented -> 2 |1 <- should not be incremented -> 2
""".trimMargin(), """.trimMargin(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -208,8 +198,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|1 <- should not be incremented 3 |1 <- should not be incremented 3
|1 <- should not be incremented 3 |1 <- should not be incremented 3
""".trimMargin(), """.trimMargin(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -29,8 +29,7 @@ class DeleteEndOfLineActionTest : VimTestCase() {
Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet,
consectetur adipiscing elit consectetur adipiscing elit
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.VimStateMachine 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.TestIjOptionConstants import org.jetbrains.plugins.ideavim.TestIjOptionConstants
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -38,8 +38,7 @@ class DeleteJoinLinesSpacesActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -61,8 +60,7 @@ class DeleteJoinLinesSpacesActionTest : VimTestCase() {
Lorem ipsum dolor sit amet, consectetur adipiscing elit$c Sed in orci mauris. Lorem ipsum dolor sit amet, consectetur adipiscing elit$c Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -87,8 +85,7 @@ class DeleteJoinLinesSpacesActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.VimStateMachine 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.TestIjOptionConstants import org.jetbrains.plugins.ideavim.TestIjOptionConstants
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -39,8 +39,7 @@ class DeleteJoinVisualLinesSpacesActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -9,7 +9,8 @@
package org.jetbrains.plugins.ideavim.action.change.delete package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.group.visual.IdeaSelectionControl import com.maddyhome.idea.vim.group.visual.IdeaSelectionControl
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -40,7 +41,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -62,7 +63,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -84,7 +85,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -106,7 +107,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT) @TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@ -125,7 +126,7 @@ class DeleteVisualActionTest : VimTestCase() {
""".trimIndent(), """.trimIndent(),
) )
IdeaSelectionControl.controlNonVimSelectionChange(fixture.editor) IdeaSelectionControl.controlNonVimSelectionChange(fixture.editor)
waitAndAssertMode(fixture, VimStateMachine.Mode.VISUAL) waitAndAssertMode(fixture, Mode.VISUAL(SelectionType.LINE_WISE))
typeText(injector.parser.parseKeys("d")) typeText(injector.parser.parseKeys("d"))
assertState( assertState(
""" """
@ -134,7 +135,7 @@ class DeleteVisualActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
) )
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) assertState(Mode.NORMAL())
} }
@Test @Test
@ -156,6 +157,6 @@ class DeleteVisualActionTest : VimTestCase() {
wh| wh|
ha| ha|
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
} }

View File

@ -10,7 +10,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -30,8 +30,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -50,8 +49,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
consectetur adipiscing elit consectetur adipiscing elit
${c}Sed in orci mauris. ${c}Sed in orci mauris.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -70,8 +68,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -90,8 +87,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
consectetur adipiscing elit consectetur adipiscing elit
${c}Sed in orci mauris. ${c}Sed in orci mauris.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -114,7 +110,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
consectetur adipiscing elit consectetur adipiscing elit
${c} ${c}
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -138,6 +134,6 @@ class DeleteVisualLinesActionTest : VimTestCase() {
${c} ${c}
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
} }

View File

@ -10,7 +10,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -674,7 +674,7 @@ class DeleteVisualLinesEndActionTest : VimTestCase() {
Today it is not working Today it is not working
The test is like that. The test is like that.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
) )
} }
} }

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -53,9 +53,8 @@ class InsertAfterLineEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
} }

View File

@ -8,14 +8,14 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class InsertBeforeCursorActionTest : VimTestCase() { class InsertBeforeCursorActionTest : VimTestCase() {
@Test @Test
fun `test check caret shape`() { fun `test check caret shape`() {
doTest("i", "123", "123", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("i", "123", "123", Mode.INSERT)
assertCaretsVisualAttributes() assertCaretsVisualAttributes()
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -33,9 +33,8 @@ class InsertBeforeFirstNonBlankActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -29,8 +29,7 @@ class InsertDeleteInsertedTextActionTest : VimTestCase() {
I found iti${c}t in a legendary land I found iti${c}t in a legendary land
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -50,8 +49,7 @@ class InsertDeleteInsertedTextActionTest : VimTestCase() {
I found ii${c}ta legendary land I found ii${c}ta legendary land
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -11,7 +11,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -28,8 +28,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
""" """
I found it in a i${c}t land I found it in a i${c}t land
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -43,8 +42,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
""" """
I ${c} it in a legendary land I ${c} it in a legendary land
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -58,8 +56,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
""" """
I ${c} in a legendary land I ${c} in a legendary land
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -75,8 +72,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
""" """
Lorem Ipsum${c} found it in a legendary land Lorem Ipsum${c} found it in a legendary land
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -106,8 +102,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
legendary legendary
${c} ${c}
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -118,8 +113,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
listOf("a", "<C-W>"), listOf("a", "<C-W>"),
"this is a sentence<caret>.\n", "this is a sentence<caret>.\n",
"this is a sentence<caret>\n", "this is a sentence<caret>\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -130,8 +124,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
listOf("A", "<C-W>"), listOf("A", "<C-W>"),
"<caret>this is a sentence\n", "<caret>this is a sentence\n",
"this is a <caret>\n", "this is a <caret>\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
@ -142,8 +135,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
listOf("A", "<C-W>"), listOf("A", "<C-W>"),
"<caret>\$variable\n", "<caret>\$variable\n",
"$<caret>\n", "$<caret>\n",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -28,7 +28,7 @@ class InsertEnterActionTest : VimTestCase() {
|Sed in orci mauris. |Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas. |Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
doTest(listOf("i", "<Enter>"), before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(listOf("i", "<Enter>"), before, after, Mode.INSERT)
} }
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES) @TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
@ -45,7 +45,7 @@ class InsertEnterActionTest : VimTestCase() {
|Sed in orci mauris. |Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas. |Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
doTest(listOf("i", "<C-M>"), before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(listOf("i", "<C-M>"), before, after, Mode.INSERT)
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)

View File

@ -8,18 +8,18 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class InsertExitModeActionTest : VimTestCase() { class InsertExitModeActionTest : VimTestCase() {
@Test @Test
fun `test exit visual mode`() { fun `test exit visual mode`() {
doTest("i<Esc>", "12${c}3", "1${c}23", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("i<Esc>", "12${c}3", "1${c}23", Mode.NORMAL())
} }
@Test @Test
fun `test exit visual mode on line start`() { fun `test exit visual mode on line start`() {
doTest("i<Esc>", "${c}123", "${c}123", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("i<Esc>", "${c}123", "${c}123", Mode.NORMAL())
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -28,7 +28,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|Sed in orci mauris. |Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas. |Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("O", before, after, Mode.INSERT)
} }
@Test @Test
@ -44,7 +44,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|where it was settled on some sodden sand |where it was settled on some sodden sand
|hard by the torrent of a mountain pass. |hard by the torrent of a mountain pass.
""".trimMargin() """.trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("O", before, after, Mode.INSERT)
} }
@Test @Test
@ -60,7 +60,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
| Sed in orci mauris. | Sed in orci mauris.
| Cras id tellus in ex imperdiet egestas. | Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("O", before, after, Mode.INSERT)
} }
@Test @Test
@ -76,7 +76,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
| Sed in orci mauris. | Sed in orci mauris.
| Cras id tellus in ex imperdiet egestas. | Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("O", before, after, Mode.INSERT)
} }
@TestWithoutNeovim(SkipNeovimReason.PLUGIN) // Java support would be a neovim plugin @TestWithoutNeovim(SkipNeovimReason.PLUGIN) // Java support would be a neovim plugin
@ -114,7 +114,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
| $c | $c
| hard by the torrent of a mountain pass. | hard by the torrent of a mountain pass.
""".trimMargin() """.trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("O", before, after, Mode.INSERT)
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -142,6 +142,6 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|Sed in orci mauris. |Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas. |Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("O", before, after, Mode.INSERT)
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -28,7 +28,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|where it was settled on some sodden sand |where it was settled on some sodden sand
|hard by the torrent of a mountain pass. |hard by the torrent of a mountain pass.
""".trimMargin() """.trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("o", before, after, Mode.INSERT)
} }
@Test @Test
@ -44,7 +44,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|where it was settled on some sodden sand |where it was settled on some sodden sand
|hard by the torrent of a mountain pass. |hard by the torrent of a mountain pass.
""".trimMargin() """.trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("o", before, after, Mode.INSERT)
} }
@Test @Test
@ -60,7 +60,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
| where it was settled on some sodden sand | where it was settled on some sodden sand
| hard by the torrent of a mountain pass. | hard by the torrent of a mountain pass.
""".trimMargin() """.trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("o", before, after, Mode.INSERT)
} }
@Test @Test
@ -76,7 +76,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
| where it was settled on some sodden sand | where it was settled on some sodden sand
| hard by the torrent of a mountain pass. | hard by the torrent of a mountain pass.
""".trimMargin() """.trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("o", before, after, Mode.INSERT)
} }
@TestWithoutNeovim(SkipNeovimReason.PLUGIN) // Java support would be a neovim plugin @TestWithoutNeovim(SkipNeovimReason.PLUGIN) // Java support would be a neovim plugin
@ -133,7 +133,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
| hard by the torrent of a mountain pass. | hard by the torrent of a mountain pass.
| $c | $c
""".trimMargin() """.trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("o", before, after, Mode.INSERT)
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -160,7 +160,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|where it was settled on some sodden sand |where it was settled on some sodden sand
|hard by the torrent of a mountain pass. |hard by the torrent of a mountain pass.
""".trimMargin() """.trimMargin()
doTest("5o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest("5o", before, after, Mode.INSERT)
} }
@Test @Test
@ -199,7 +199,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
configureAndFold(before, "") configureAndFold(before, "")
performTest("o", after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) performTest("o", after, Mode.INSERT)
} }
@TestWithoutNeovim(reason = SkipNeovimReason.FOLDING, "Neovim doesn't support arbitrary folds") @TestWithoutNeovim(reason = SkipNeovimReason.FOLDING, "Neovim doesn't support arbitrary folds")
@ -219,7 +219,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
configureAndFold(before, "") configureAndFold(before, "")
performTest("o", after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) performTest("o", after, Mode.INSERT)
} }
@Test @Test
@ -238,6 +238,6 @@ class InsertNewLineBelowActionTest : VimTestCase() {
configureAndFold(before, "") configureAndFold(before, "")
performTest("o", after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) performTest("o", after, Mode.INSERT)
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -19,8 +19,7 @@ class InsertSingleCommandActionTest : VimTestCase() {
listOf("i", "<C-O>", "vlll", "<Esc>"), listOf("i", "<C-O>", "vlll", "<Esc>"),
"I found ${c}it in a legendary land", "I found ${c}it in a legendary land",
"I found it ${c}in a legendary land", "I found it ${c}in a legendary land",
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -70,9 +70,8 @@ class VisualBlockAppendActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
} }

View File

@ -12,7 +12,7 @@ import com.intellij.codeInsight.daemon.impl.HintRenderer
import com.intellij.codeInsight.folding.CodeFoldingManager import com.intellij.codeInsight.folding.CodeFoldingManager
import com.intellij.codeInsight.folding.impl.FoldingUtil import com.intellij.codeInsight.folding.impl.FoldingUtil
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -200,8 +200,7 @@ Xbar
listOf("<C-V>", "lll", "I"), listOf("<C-V>", "lll", "I"),
before.trimIndent(), before.trimIndent(),
before.trimIndent(), before.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -12,7 +12,7 @@ import com.intellij.notification.EventLog
import com.intellij.notification.Notification import com.intellij.notification.Notification
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.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.group.NotificationService import com.maddyhome.idea.vim.group.NotificationService
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants

View File

@ -18,8 +18,8 @@ import com.intellij.testFramework.ExtensionTestUtil
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
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.SelectionType import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
@ -49,8 +49,7 @@ class PutTestAfterCursorActionTest : VimTestCase() {
"\"4p", "\"4p",
"This is my$c text", "This is my$c text",
"This is my XXX$c text", "This is my XXX$c text",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
kotlin.test.assertEquals(1, extension.calledExtractTransferableData) kotlin.test.assertEquals(1, extension.calledExtractTransferableData)
} }
@ -62,8 +61,7 @@ class PutTestAfterCursorActionTest : VimTestCase() {
"\"4p", "\"4p",
"This is my$c text", "This is my$c text",
"This is my XXX$c text", "This is my XXX$c text",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.copy package org.jetbrains.plugins.ideavim.action.copy
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.jetbrains.plugins.ideavim.rangeOf import org.jetbrains.plugins.ideavim.rangeOf

View File

@ -13,7 +13,7 @@ import com.intellij.ide.CopyPasteManagerEx
import com.intellij.openapi.ide.CopyPasteManager import com.intellij.openapi.ide.CopyPasteManager
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.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason

View File

@ -12,7 +12,7 @@ package org.jetbrains.plugins.ideavim.action.copy
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.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason

View File

@ -10,7 +10,7 @@ package org.jetbrains.plugins.ideavim.action.copy
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.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.TextRange import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim

View File

@ -12,7 +12,7 @@ package org.jetbrains.plugins.ideavim.action.copy
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.command.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason

View File

@ -10,7 +10,7 @@ package org.jetbrains.plugins.ideavim.action.copy
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.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -57,7 +57,7 @@ class YankVisualLinesActionTest : VimTestCase() {
${c}where it was settled on some sodden sand ${c}where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest("vjY", text, textAfter, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest("vjY", text, textAfter, Mode.NORMAL())
val yankedTest = """ val yankedTest = """
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.

View File

@ -12,7 +12,7 @@ package org.jetbrains.plugins.ideavim.action.motion.gn
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.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.common.Direction import com.maddyhome.idea.vim.common.Direction
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -79,8 +79,7 @@ class GnNextTextObjectTest : VimTestCase() {
listOf("/is<CR>", ":s/test/tester/<CR>", "0", "dgn"), listOf("/is<CR>", ":s/test/tester/<CR>", "0", "dgn"),
"Hello, ${c}this is a test here", "Hello, ${c}this is a test here",
"Hello, this is a ${c}er here", "Hello, this is a ${c}er here",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -89,6 +88,6 @@ class GnNextTextObjectTest : VimTestCase() {
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS) VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
typeText(keys) typeText(keys)
assertState(after) assertState(after)
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) assertState(Mode.NORMAL())
} }
} }

View File

@ -12,7 +12,7 @@ package org.jetbrains.plugins.ideavim.action.motion.gn
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.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.common.Direction import com.maddyhome.idea.vim.common.Direction
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -57,8 +57,7 @@ class GnPreviousTextObjectTest : VimTestCase() {
listOf("/is<CR>", ":s/test/tester/<CR>", "$", "dgN"), listOf("/is<CR>", ":s/test/tester/<CR>", "$", "dgN"),
"Hello, ${c}this is a test here", "Hello, ${c}this is a test here",
"Hello, this is a ${c}er here", "Hello, this is a ${c}er here",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -67,6 +66,6 @@ class GnPreviousTextObjectTest : VimTestCase() {
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS) VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
typeText(keys) typeText(keys)
assertState(after) assertState(after)
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) assertState(Mode.NORMAL())
} }
} }

View File

@ -11,7 +11,8 @@ import com.intellij.idea.TestFor
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.Direction import com.maddyhome.idea.vim.common.Direction
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -26,7 +27,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "b" + "gn"), "h<caret>ello world\nhello world hello world") typeTextInFile(injector.parser.parseKeys("*" + "b" + "gn"), "h<caret>ello world\nhello world hello world")
assertOffset(16) assertOffset(16)
assertSelection("hello") assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -37,7 +38,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
"h<caret>ello world\nh<caret>ello world hello world", "h<caret>ello world\nh<caret>ello world hello world",
) )
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount) kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -49,7 +50,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
) )
assertOffset(0) assertOffset(0)
assertSelection("h") assertSelection("h")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR) @TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
@ -60,7 +61,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeText(injector.parser.parseKeys("gn")) typeText(injector.parser.parseKeys("gn"))
assertOffset(7) assertOffset(7)
assertSelection("test") assertSelection("test")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -69,7 +70,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gn"), "h<caret>ello world\nhello world hello world") typeTextInFile(injector.parser.parseKeys("*" + "gn"), "h<caret>ello world\nhello world hello world")
assertOffset(16) assertOffset(16)
assertSelection("hello") assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -97,7 +98,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gn" + "gn"), "h<caret>ello world\nhello world hello, hello") typeTextInFile(injector.parser.parseKeys("*" + "gn" + "gn"), "h<caret>ello world\nhello world hello, hello")
assertOffset(28) assertOffset(28)
assertSelection("hello world hello") assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -109,7 +110,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
) )
assertOffset(28) assertOffset(28)
assertSelection(null) assertSelection(null)
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
@Test @Test
@ -125,7 +126,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*0e" + "gn"), "h<caret>ello hello") typeTextInFile(injector.parser.parseKeys("*0e" + "gn"), "h<caret>ello hello")
assertOffset(4) assertOffset(4)
assertSelection("hello") assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -134,7 +135,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*0llv" + "gn"), "h<caret>ello hello") typeTextInFile(injector.parser.parseKeys("*0llv" + "gn"), "h<caret>ello hello")
assertOffset(4) assertOffset(4)
assertSelection("llo") assertSelection("llo")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -143,7 +144,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*0ev" + "gn"), "h<caret>ello hello") typeTextInFile(injector.parser.parseKeys("*0ev" + "gn"), "h<caret>ello hello")
assertOffset(10) assertOffset(10)
assertSelection("o hello") assertSelection("o hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -155,7 +156,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
) )
assertOffset(28) assertOffset(28)
assertSelection("hello world hello") assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -167,7 +168,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
) )
assertOffset(28) assertOffset(28)
assertSelection("hello world hello") assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])

View File

@ -11,7 +11,8 @@ import com.intellij.idea.TestFor
import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.Direction import com.maddyhome.idea.vim.common.Direction
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -26,7 +27,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*w" + "gN"), "h<caret>ello world\nhello world hello world") typeTextInFile(injector.parser.parseKeys("*w" + "gN"), "h<caret>ello world\nhello world hello world")
assertOffset(12) assertOffset(12)
assertSelection("hello") assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -37,7 +38,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
"h<caret>ello world\nh<caret>ello world hello world", "h<caret>ello world\nh<caret>ello world hello world",
) )
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount) kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -46,7 +47,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gN"), "h<caret>ello world\nhello world hello world") typeTextInFile(injector.parser.parseKeys("*" + "gN"), "h<caret>ello world\nhello world hello world")
assertOffset(12) assertOffset(12)
assertSelection("hello") assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT) @TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
@ -57,7 +58,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeText(injector.parser.parseKeys("gN")) typeText(injector.parser.parseKeys("gN"))
assertOffset(0) assertOffset(0)
assertSelection("test") assertSelection("test")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -74,7 +75,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN"), "hello world\nh<caret>ello world hello") typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN"), "hello world\nh<caret>ello world hello")
assertOffset(12) assertOffset(12)
assertSelection("hello world hello") assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -83,7 +84,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN" + "<Esc>"), "hello world\nh<caret>ello world hello") typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN" + "<Esc>"), "hello world\nh<caret>ello world hello")
assertOffset(12) assertOffset(12)
assertSelection(null) assertSelection(null)
assertMode(VimStateMachine.Mode.COMMAND) assertMode(Mode.NORMAL())
} }
@TestFor(classes = [SearchWholeWordForwardAction::class]) @TestFor(classes = [SearchWholeWordForwardAction::class])
@ -92,7 +93,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*llv" + "gN"), "hello hello") typeTextInFile(injector.parser.parseKeys("*llv" + "gN"), "hello hello")
assertOffset(6) assertOffset(6)
assertSelection("hel") assertSelection("hel")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@Test @Test
@ -100,6 +101,6 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN"), "hello 1\n\thello 2\n\the<caret>llo 3\n\thello 4") typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN"), "hello 1\n\thello 2\n\the<caret>llo 3\n\thello 4")
assertOffset(18) assertOffset(18)
assertSelection("hello 3\n\thello") assertSelection("hello 3\n\thello")
assertMode(VimStateMachine.Mode.VISUAL) assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
} }

View File

@ -11,7 +11,8 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -247,8 +248,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.VISUAL, Mode.VISUAL(SelectionType.CHARACTER_WISE),
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -273,8 +273,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -299,8 +298,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.VISUAL, Mode.VISUAL(SelectionType.CHARACTER_WISE),
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -325,8 +323,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -351,8 +348,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }

View File

@ -11,7 +11,8 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -205,8 +206,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.VISUAL, Mode.VISUAL(SelectionType.CHARACTER_WISE),
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -231,8 +231,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -257,8 +256,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.VISUAL, Mode.VISUAL(SelectionType.CHARACTER_WISE),
VimStateMachine.SubMode.VISUAL_CHARACTER,
) )
} }
@ -283,8 +281,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -309,8 +306,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }

View File

@ -10,7 +10,8 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -42,7 +43,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -65,7 +66,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER) doTest(keys, before, after, Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -88,7 +89,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER) doTest(keys, before, after, Mode.SELECT(SelectionType.CHARACTER_WISE))
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -111,7 +112,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -134,7 +135,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -157,7 +158,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(SkipNeovimReason.NON_ASCII) @TestWithoutNeovim(SkipNeovimReason.NON_ASCII)
@ -180,6 +181,6 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
} }

View File

@ -10,7 +10,8 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.options.OptionConstants import com.maddyhome.idea.vim.options.OptionConstants
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -43,7 +44,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@OptionTest(VimOption(TestOptionConstants.keymodel, doesntAffectTest = true)) @OptionTest(VimOption(TestOptionConstants.keymodel, doesntAffectTest = true))
@ -72,7 +73,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER) doTest(keys, before, after, Mode.VISUAL(SelectionType.CHARACTER_WISE))
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -95,7 +96,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER) doTest(keys, before, after, Mode.SELECT(SelectionType.CHARACTER_WISE))
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -118,7 +119,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@TestWithoutNeovim(SkipNeovimReason.OPTION) @TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -141,6 +142,6 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
} }

View File

@ -10,7 +10,8 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -37,7 +38,7 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -59,7 +60,7 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.NORMAL())
} }
@Test @Test
@ -81,7 +82,7 @@ class MotionLastColumnActionTest : VimTestCase() {
wh${s}ere it was settled on some sodden sand${c}${se} wh${s}ere it was settled on some sodden sand${c}${se}
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK) doTest(keys, before, after, Mode.VISUAL(SelectionType.BLOCK_WISE))
} }
@Test @Test
@ -136,7 +137,7 @@ class MotionLastColumnActionTest : VimTestCase() {
wh${s}ere it was settled on some sodden san${c}d${se} wh${s}ere it was settled on some sodden san${c}d${se}
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK) doTest(keys, before, after, Mode.VISUAL(SelectionType.BLOCK_WISE))
} }
@Test @Test
@ -158,7 +159,7 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES) @TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
@ -181,6 +182,6 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand where it was settled on some sodden sand
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE) doTest(keys, before, after, Mode.INSERT)
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.command.VimStateMachine 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
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
@ -26,7 +26,7 @@ class MotionLeftInsertTest : VimTestCase() {
""" """
Oh, hi M${c}ark Oh, hi M${c}ark
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
) { ) {
enterCommand("set whichwrap=[") enterCommand("set whichwrap=[")
} }
@ -43,7 +43,7 @@ class MotionLeftInsertTest : VimTestCase() {
""" """
${c}Oh, hi Mark ${c}Oh, hi Mark
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
) { ) {
enterCommand("set whichwrap=[") enterCommand("set whichwrap=[")
} }
@ -62,7 +62,7 @@ class MotionLeftInsertTest : VimTestCase() {
Oh, hi Mark$c Oh, hi Mark$c
You are my favourite customer You are my favourite customer
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
) { ) {
enterCommand("set whichwrap=[") enterCommand("set whichwrap=[")
} }
@ -85,7 +85,7 @@ class MotionLeftInsertTest : VimTestCase() {
You are my favourite customer You are my favourite customer
""".trimIndent(), """.trimIndent(),
VimStateMachine.Mode.INSERT, Mode.INSERT,
) { ) {
enterCommand("set whichwrap=[") enterCommand("set whichwrap=[")
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -19,8 +19,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx;", "Fx;",
"hello x hello x hello$c", "hello x hello x hello$c",
"hello ${c}x hello x hello", "hello ${c}x hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -30,8 +29,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx;;", "Fx;;",
"hello x hello x hello x hello$c", "hello x hello x hello x hello$c",
"hello ${c}x hello x hello x hello", "hello ${c}x hello x hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -41,8 +39,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx2;", "Fx2;",
"hello x hello x hello x hello$c", "hello x hello x hello x hello$c",
"hello ${c}x hello x hello x hello", "hello ${c}x hello x hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -52,8 +49,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx3;", "Fx3;",
"hello x hello x hello x hello x hello$c", "hello x hello x hello x hello x hello$c",
"hello ${c}x hello x hello x hello x hello", "hello ${c}x hello x hello x hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright package org.jetbrains.plugins.ideavim.action.motion.leftright
import com.maddyhome.idea.vim.command.VimStateMachine import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -19,8 +19,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx;", "Tx;",
"hello x hello x hello$c", "hello x hello x hello$c",
"hello x$c hello x hello", "hello x$c hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -30,8 +29,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx;;", "Tx;;",
"hello x hello x hello x hello$c", "hello x hello x hello x hello$c",
"hello x$c hello x hello x hello", "hello x$c hello x hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -41,8 +39,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx2;", "Tx2;",
"hello x hello x hello x hello$c", "hello x hello x hello x hello$c",
"hello x hello x$c hello x hello", "hello x hello x$c hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
@ -52,8 +49,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx3;", "Tx3;",
"hello x hello x hello x hello$c", "hello x hello x hello x hello$c",
"hello x$c hello x hello x hello", "hello x$c hello x hello x hello",
VimStateMachine.Mode.COMMAND, Mode.NORMAL(),
VimStateMachine.SubMode.NONE,
) )
} }
} }

Some files were not shown because too many files have changed in this diff Show More