1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-28 16:34:10 +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.isPrimaryEditor
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.key.ShortcutOwner
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.newapi.globalIjOptions
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 java.awt.event.InputEvent
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.CommandFlags
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.argumentCaptured
import com.maddyhome.idea.vim.group.MotionGroup

View File

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

View File

@ -11,6 +11,8 @@ package com.maddyhome.idea.vim.command
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.helper.vimStateMachine
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
@ -22,7 +24,18 @@ public class CommandState(private val machine: VimStateMachine) {
get() = machine.isOperatorPending
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
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) {
CommandState.SubMode.NONE -> VimStateMachine.SubMode.NONE
CommandState.SubMode.VISUAL_CHARACTER -> VimStateMachine.SubMode.VISUAL_CHARACTER
CommandState.SubMode.VISUAL_LINE -> VimStateMachine.SubMode.VISUAL_LINE
CommandState.SubMode.VISUAL_BLOCK -> VimStateMachine.SubMode.VISUAL_BLOCK
}
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
CommandState.SubMode.NONE -> error("Unexpected value")
CommandState.SubMode.VISUAL_CHARACTER -> SelectionType.CHARACTER_WISE
CommandState.SubMode.VISUAL_LINE -> SelectionType.LINE_WISE
CommandState.SubMode.VISUAL_BLOCK -> SelectionType.BLOCK_WISE
}

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.injector
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.CommandAliasHandler
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.newapi.IjVimCaret;
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 org.jetbrains.annotations.Nls;
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) {
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());
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);
if (range != null) {
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);
} else {
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.CommandFlags
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.SelectionType
import com.maddyhome.idea.vim.state.mode.SelectionType
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.TextRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
@ -61,7 +61,7 @@ internal class CommentaryExtension : VimExtension {
resetCaret: Boolean,
): Boolean {
val mode = editor.vimStateMachine.mode
if (mode !== VimStateMachine.Mode.VISUAL) {
if (mode !is Mode.VISUAL) {
editor.ij.selectionModel.setSelection(range.startOffset, range.endOffset)
}
@ -88,13 +88,13 @@ internal class CommentaryExtension : VimExtension {
}
private fun afterCommenting(
mode: VimStateMachine.Mode,
mode: Mode,
editor: VimEditor,
resetCaret: Boolean,
range: TextRange,
) {
// Remove the selection, if we added it
if (mode !== VimStateMachine.Mode.VISUAL) {
if (mode !is Mode.VISUAL) {
editor.removeSelection()
}
@ -159,9 +159,9 @@ internal class CommentaryExtension : VimExtension {
}
// 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
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.command.MappingMode
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.SelectionType
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.extension.ExtensionHandler
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.setRegister
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.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.mark.Mark
import com.maddyhome.idea.vim.mark.VimMarkConstants
@ -86,7 +87,7 @@ internal class VimExchangeExtension : VimExtension {
val EXCHANGE_KEY = Key<Exchange>("exchange")
// 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
fun setHighlighter(highlighter: RangeHighlighter) {
myHighlighter = highlighter
@ -121,33 +122,32 @@ internal class VimExchangeExtension : VimExtension {
private class VExchangeHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
runWriteAction {
val subMode = editor.subMode
val mode = editor.mode
// Leave visual mode to create selection marks
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 {
fun Editor.getMarkOffset(mark: Mark) = IjVimEditor(this).getOffset(mark.line, mark.col)
fun VimStateMachine.SubMode.getString() = when (this) {
VimStateMachine.SubMode.VISUAL_CHARACTER -> "v"
VimStateMachine.SubMode.VISUAL_LINE -> "V"
VimStateMachine.SubMode.VISUAL_BLOCK -> "\\<C-V>"
else -> error("Invalid SubMode: $this")
fun SelectionType.getString() = when (this) {
SelectionType.CHARACTER_WISE -> "v"
SelectionType.LINE_WISE -> "V"
SelectionType.BLOCK_WISE -> "\\<C-V>"
}
override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType): Boolean {
override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType?): Boolean {
val ijEditor = editor.ij
fun highlightExchange(ex: Exchange): RangeHighlighter {
val attributes = ijEditor.colorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES)
val hlArea = when (ex.type) {
VimStateMachine.SubMode.VISUAL_LINE -> HighlighterTargetArea.LINES_IN_RANGE
SelectionType.LINE_WISE -> HighlighterTargetArea.LINES_IN_RANGE
// TODO: handle other modes
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
return ijEditor.markupModel.addRangeHighlighter(
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)
if (exchange1 == null) {
val highlighter = highlightExchange(currentExchange)
@ -203,7 +203,7 @@ internal class VimExchangeExtension : VimExtension {
TextRange(editor.getMarkOffset(targetExchange.start), editor.getMarkOffset(targetExchange.end) + 1),
)
// 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)
}
@ -269,7 +269,7 @@ internal class VimExchangeExtension : VimExtension {
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 {
intersects(x, y) -> {
ExchangeCompareResult.OVERLAP
@ -348,9 +348,9 @@ internal class VimExchangeExtension : VimExtension {
setRegister('+', plusRegText)
return if (selectionStart.offset(editor.vim) <= selectionEnd.offset(editor.vim)) {
Exchange(selectionType.toSubMode(), selectionStart, selectionEnd, text)
Exchange(selectionType, selectionStart, selectionEnd, text)
} 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.command.MappingMode
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.extension.ExtensionHandler
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.ij
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.SelectionType
import kotlin.math.max
import kotlin.math.min
@ -312,7 +312,7 @@ internal class VimMultipleCursorsExtension : VimExtension {
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
VimPlugin.getVisualMotion().enterVisualMode(editor, VimStateMachine.SubMode.VISUAL_CHARACTER)
VimPlugin.getVisualMotion().enterVisualMode(editor, SelectionType.CHARACTER_WISE)
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.injector
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.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.isLine
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.state.mode.SelectionType.CHARACTER_WISE
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.extension.ExtensionHandler
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.group.visual.VimSelection
import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.newapi.IjVimEditor
@ -56,7 +57,7 @@ internal class ReplaceWithRegister : VimExtension {
private class RwrVisual : ExtensionHandler {
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 ->
val selectionStart = caret.selectionStart
val selectionEnd = caret.selectionEnd
@ -103,7 +104,7 @@ internal class ReplaceWithRegister : VimExtension {
}
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 range = getRange(ijEditor) ?: return false
val visualSelection = PutData.VisualSelection(
@ -111,11 +112,11 @@ internal class ReplaceWithRegister : VimExtension {
editor.primaryCaret() to VimSelection.create(
range.startOffset,
range.endOffset - 1,
selectionType,
selectionType ?: CHARACTER_WISE,
editor,
),
),
selectionType,
selectionType ?: CHARACTER_WISE,
)
// todo multicaret
doReplace(ijEditor, editor.primaryCaret(), visualSelection)
@ -124,8 +125,8 @@ internal class ReplaceWithRegister : VimExtension {
// todo make it work with multiple carets
private fun getRange(editor: Editor): TextRange? = when (editor.vim.mode) {
VimStateMachine.Mode.COMMAND -> injector.markService.getChangeMarks(editor.caretModel.primaryCaret.vim)
VimStateMachine.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
is Mode.NORMAL -> injector.markService.getChangeMarks(editor.caretModel.primaryCaret.vim)
is Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
else -> null
}
}
@ -173,7 +174,6 @@ internal class ReplaceWithRegister : VimExtension {
editor.vimStateMachine?.isOperatorPending ?: false,
0,
editor.vim.mode,
editor.vim.subMode,
),
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.setChangeMarks
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.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.state.mode.selectionType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.ExtensionHandler
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.setOperatorFunction
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setRegisterForCaret
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim
@ -122,7 +122,7 @@ internal class VimSurroundExtension : VimExtension {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
val selectionStart = editor.ij.caretModel.primaryCaret.selectionStart
// NB: Operator ignores SelectionType anyway
if (!Operator().apply(editor, context, SelectionType.fromSubMode(editor.subMode))) {
if (!Operator().apply(editor, context, editor.mode.selectionType)) {
return
}
runWriteAction {
@ -256,7 +256,7 @@ internal class VimSurroundExtension : VimExtension {
}
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 c = getChar(ijEditor)
if (c.code == 0) return true
@ -274,8 +274,8 @@ internal class VimSurroundExtension : VimExtension {
val editor = caret.editor
val ijEditor = editor.ij
return when (ijEditor.vim.mode) {
VimStateMachine.Mode.COMMAND -> injector.markService.getChangeMarks(caret)
VimStateMachine.Mode.VISUAL -> caret.run { TextRange(selectionStart, selectionEnd) }
is Mode.NORMAL -> injector.markService.getChangeMarks(caret)
is Mode.VISUAL -> caret.run { TextRange(selectionStart, selectionEnd) }
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.newapi.IjVimCaret;
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.Nullable;
@ -131,7 +133,7 @@ public class VimTextObjEntireExtension implements VimExtension {
@Override
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());
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);
if (range != null) {
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);
} else {
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.newapi.IjVimCaret;
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.Nullable;
@ -260,7 +262,7 @@ public class VimIndentObject implements VimExtension {
@Override
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) {
IjVimEditor vimEditor = (IjVimEditor)editor;
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(vimEditor);
@NotNull VimStateMachine vimStateMachine = VimStateMachine.Companion.getInstance(vimEditor);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
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);
if (range != null) {
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);
} else {
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.IjVimCaret;
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 kotlin.Pair;
import kotlin.Unit;
@ -177,8 +179,8 @@ public class ChangeGroup extends VimChangeGroupBase {
final int lines = VimChangeGroupBase.Companion.getLinesCountInVisualBlock(editor, range);
final BufferPosition startPosition = editor.offsetToBufferPosition(range.getStartOffset());
boolean visualBlockMode = operatorArguments.getMode() == VimStateMachine.Mode.VISUAL &&
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK;
boolean visualBlockMode =
operatorArguments.getMode() instanceof Mode.VISUAL mode && mode.getSelectionType() == SelectionType.BLOCK_WISE;
for (VimCaret caret : editor.carets()) {
final int line = startPosition.getLine();
int column = startPosition.getColumn();

View File

@ -30,7 +30,8 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.ProjectScope;
import com.maddyhome.idea.vim.VimPlugin;
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.helper.EditorHelper;
import com.maddyhome.idea.vim.helper.EditorHelperRt;
@ -296,7 +297,7 @@ public class FileGroup extends VimFileBase {
StringBuilder msg = new StringBuilder();
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();
int col = editor.getCaretModel().getOffset() - doc.getLineStartOffset(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.command.Argument
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.VimStateMachine
import com.maddyhome.idea.vim.state.VimStateMachine
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.handler.Motion
@ -460,7 +461,7 @@ internal class MotionGroup : VimMotionGroupBase() {
val editor = fileEditor.editor
ExOutputModel.getInstance(editor).clear()
editor.vim.let { vimEditor ->
if (VimStateMachine.getInstance(vimEditor).mode === VimStateMachine.Mode.VISUAL) {
if (VimStateMachine.getInstance(vimEditor).mode is Mode.VISUAL) {
vimEditor.exitVisualMode()
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.VimProcessGroupBase;
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.InvalidCommandException;
import com.maddyhome.idea.vim.helper.UiHelper;
@ -81,7 +82,8 @@ public class ProcessGroup extends VimProcessGroupBase {
if (editor.isOneLineMode()) return;
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();
panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
}
@ -99,7 +101,7 @@ public class ProcessGroup extends VimProcessGroupBase {
return true;
}
else {
VimStateMachine.getInstance(editor).popModes();
VimStateMachine.Companion.getInstance(editor).setMode(new Mode.NORMAL());
KeyHandler.getInstance().reset(editor);
return false;
}
@ -110,7 +112,7 @@ public class ProcessGroup extends VimProcessGroupBase {
panel.deactivate(true);
boolean res = true;
try {
VimStateMachine.getInstance(editor).popModes();
VimStateMachine.Companion.getInstance(editor).setMode(new Mode.NORMAL());
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
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) {
VimStateMachine.getInstance(editor).popModes();
VimStateMachine.Companion.getInstance(editor).setMode(new Mode.NORMAL());
KeyHandler.getInstance().reset(editor);
ExEntryPanel panel = ExEntryPanel.getInstance();
panel.deactivate(true, resetCaret);
@ -156,14 +158,14 @@ public class ProcessGroup extends VimProcessGroupBase {
@Override
public void startFilterCommand(@NotNull VimEditor editor, ExecutionContext context, @NotNull Command 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();
panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
}
private @NotNull String getRange(Editor editor, @NotNull Command cmd) {
String initText = "";
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
if (VimStateMachine.Companion.getInstance(new IjVimEditor(editor)).getMode() instanceof Mode.VISUAL) {
initText = "'<,'>";
}
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.diagnostic.Logger;
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.VimRegisterGroupBase;
import org.jdom.Element;
@ -50,7 +50,7 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
}
final Element registerElement = new Element("register");
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();
if (text != null) {
logger.trace("Save register as 'text'");
@ -95,7 +95,25 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
final Register register;
final Element textElement = registerElement.getChild("text");
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) {
logger.trace("Register has 'text' element");
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.injector
import com.maddyhome.idea.vim.api.setChangeMarks
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.isBlock
import com.maddyhome.idea.vim.command.isChar
import com.maddyhome.idea.vim.command.isLine
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.state.mode.isBlock
import com.maddyhome.idea.vim.state.mode.isChar
import com.maddyhome.idea.vim.state.mode.isLine
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.diagnostic.debug
import com.maddyhome.idea.vim.helper.EditorHelper
@ -74,7 +73,7 @@ internal class PutGroup : VimPutBase() {
vimEditor: VimEditor,
vimContext: ExecutionContext,
text: ProcessedTextData,
subMode: VimStateMachine.SubMode,
subMode: SelectionType,
data: PutData,
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.api.injector
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.exitVisualMode
import com.maddyhome.idea.vim.helper.hasVisualSelection
import com.maddyhome.idea.vim.helper.inInsertMode
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.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.listener.VimListenerManager
import com.maddyhome.idea.vim.newapi.vim
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.isIdeaRefactorModeKeep
import com.maddyhome.idea.vim.vimscript.model.options.helpers.isIdeaRefactorModeSelect
@ -70,17 +70,17 @@ internal object IdeaSelectionControl {
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))
} 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.inSelectMode) editor.exitSelectMode(false)
if (editor.vim.mode.inNormalMode) {
if (editor.vim.inNormalMode) {
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
* (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 (dontChangeMode(editor)) return editor.vim.mode
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) {
VimStateMachine.Mode.VISUAL -> VimPlugin.getVisualMotion()
.enterVisualMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
VimStateMachine.Mode.SELECT -> VimPlugin.getVisualMotion()
.enterSelectMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
VimStateMachine.Mode.INSERT -> VimPlugin.getChange().insertBeforeCursor(
editor.vim,
injector.executionContextManager.onEditor(editor.vim),
)
VimStateMachine.Mode.COMMAND -> Unit
is Mode.VISUAL -> VimPlugin.getVisualMotion().enterVisualMode(editor.vim, mode.selectionType)
is Mode.SELECT -> VimPlugin.getVisualMotion().enterSelectMode(editor.vim, mode.selectionType)
is Mode.INSERT -> VimPlugin.getChange()
.insertBeforeCursor(editor.vim, injector.executionContextManager.onEditor(editor.vim))
is Mode.NORMAL -> Unit
else -> error("Unexpected mode: $mode")
}
}
@ -127,40 +124,40 @@ internal object IdeaSelectionControl {
private fun dontChangeMode(editor: Editor): Boolean =
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()
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(
editor: Editor,
selectionSource: VimListenerManager.SelectionSource,
logReason: Boolean,
): VimStateMachine.Mode {
): Mode {
val selectmode = injector.options(editor.vim).selectmode
return when {
editor.isOneLineMode -> {
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 -> {
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 -> {
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 -> {
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 -> {
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
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.singleTask
import com.maddyhome.idea.vim.newapi.globalIjOptions
@ -55,9 +55,9 @@ import javax.swing.Timer
internal object VimVisualTimer {
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()
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)
swingTimer = null
mode = null

View File

@ -12,16 +12,16 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.api.getLineEndForOffset
import com.maddyhome.idea.vim.api.getLineStartForOffset
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.inBlockSubMode
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.inBlockSelection
import com.maddyhome.idea.vim.helper.isEndAllowed
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.vimSelectionStart
import com.maddyhome.idea.vim.newapi.IjVimEditor
import com.maddyhome.idea.vim.newapi.vim
internal fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode: VimStateMachine.Mode) {
if (predictedMode != VimStateMachine.Mode.VISUAL) {
internal fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode: Mode) {
if (predictedMode !is Mode.VISUAL) {
if (!editor.vim.isEndAllowed(predictedMode)) {
editor.caretModel.allCarets.forEach { caret ->
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) {
vimSelectionStart = start
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.VimVisualMotionGroupBase
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.newapi.ij
import com.maddyhome.idea.vim.newapi.vim
@ -22,11 +22,11 @@ import com.maddyhome.idea.vim.newapi.vim
* @author Alex Plate
*/
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.
val project = editor.ij.project
if (project != null && FindManager.getInstance(project).selectNextOccurrenceWasPerformed()) {
return VimStateMachine.SubMode.VISUAL_CHARACTER
return SelectionType.CHARACTER_WISE
}
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.globalOptions
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.vim
import com.maddyhome.idea.vim.options.EffectiveOptionValueChangeListener
import com.maddyhome.idea.vim.options.helpers.GuiCursorMode
import com.maddyhome.idea.vim.options.helpers.GuiCursorOptionHelper
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 java.awt.Color
@ -66,28 +67,7 @@ internal object GuicursorChangeListener : EffectiveOptionValueChangeListener {
}
private fun Editor.guicursorMode(): GuiCursorMode {
if (this.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
}
return GuiCursorMode.fromMode(vim.mode, vim.vimStateMachine.isReplaceCharacter)
}
/**
@ -107,7 +87,7 @@ private fun Editor.updatePrimaryCaretVisualAttributes() {
private fun Editor.updateSecondaryCaretsVisualAttributes() {
// 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 {
if (it != this.caretModel.primaryCaret) {
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.injector
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.options.OptionConstants
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) {
VimStateMachine.Mode.VISUAL, VimStateMachine.Mode.SELECT -> true
VimStateMachine.Mode.REPLACE, VimStateMachine.Mode.CMD_LINE, VimStateMachine.Mode.COMMAND, VimStateMachine.Mode.INSERT, VimStateMachine.Mode.OP_PENDING -> false
VimStateMachine.Mode.INSERT_NORMAL -> false
VimStateMachine.Mode.INSERT_VISUAL -> true
VimStateMachine.Mode.INSERT_SELECT -> true
is Mode.VISUAL, is Mode.SELECT -> true
else -> false
}
/**
@ -36,7 +33,18 @@ internal val VimStateMachine.Mode.hasVisualSelection
* Please see: https://jb.gg/zo8n0r
*/
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
@ -51,21 +59,24 @@ public val CommandState.Mode.isEndAllowed: Boolean
return injector.optionGroup.hasValue(Options.virtualedit, OptionScope.GLOBAL, OptionConstants.virtualedit_onemore)
}
return when (this.engine) {
VimStateMachine.Mode.INSERT, VimStateMachine.Mode.VISUAL, VimStateMachine.Mode.SELECT -> true
VimStateMachine.Mode.COMMAND, VimStateMachine.Mode.CMD_LINE, VimStateMachine.Mode.REPLACE, VimStateMachine.Mode.OP_PENDING -> possiblyUsesVirtualSpace()
VimStateMachine.Mode.INSERT_NORMAL, VimStateMachine.Mode.INSERT_VISUAL, VimStateMachine.Mode.INSERT_SELECT -> possiblyUsesVirtualSpace()
return when (this) {
CommandState.Mode.INSERT, CommandState.Mode.VISUAL, CommandState.Mode.SELECT -> true
CommandState.Mode.COMMAND, CommandState.Mode.CMD_LINE, CommandState.Mode.REPLACE, CommandState.Mode.OP_PENDING -> possiblyUsesVirtualSpace()
CommandState.Mode.INSERT_NORMAL, CommandState.Mode.INSERT_VISUAL, CommandState.Mode.INSERT_SELECT -> possiblyUsesVirtualSpace()
}
}
@get:JvmName("inNormalMode")
public val VimStateMachine.Mode.inNormalMode: Boolean
get() = this == VimStateMachine.Mode.COMMAND || this == VimStateMachine.Mode.INSERT_NORMAL
public val Mode.inNormalMode: Boolean
get() = this is Mode.NORMAL
@get:JvmName("inInsertMode")
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")
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.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.inBlockSelection
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()
internal inline fun Editor.vimForEachCaret(action: (caret: Caret) -> Unit) {
if (this.vim.inBlockSubMode) {
if (this.vim.inBlockSelection) {
action(this.caretModel.primaryCaret)
} else {
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.getLineStartForOffset
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.newapi.IjEditorExecutionContext
import com.maddyhome.idea.vim.newapi.IjVimCaret
import com.maddyhome.idea.vim.newapi.IjVimEditor
import com.maddyhome.idea.vim.newapi.vim
/**
* Pop all modes, but leave editor state. E.g. editor selection is not removed.
*/
internal fun Editor.popAllModes() {
val commandState = this.vim.vimStateMachine
while (commandState.mode != VimStateMachine.Mode.COMMAND) {
commandState.popModes()
}
}
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.ReturnTo
import com.maddyhome.idea.vim.state.mode.inSelectMode
import com.maddyhome.idea.vim.state.mode.returnTo
/** [adjustCaretPosition] - if true, caret will be moved one char left if it's on the line end */
internal fun Editor.exitSelectMode(adjustCaretPosition: Boolean) {
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 {
this.caretModel.allCarets.forEach {
it.removeSelection()
@ -58,7 +64,20 @@ internal fun Editor.exitSelectMode(adjustCaretPosition: Boolean) {
internal fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) {
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 {
this.carets().forEach { vimCaret ->
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.options
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.getApproximateScreenWidth
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.api.EngineEditorHelperKt;
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.Direction;
import com.maddyhome.idea.vim.common.TextRange;
@ -858,8 +859,8 @@ public class SearchHelper {
selectionEndWithoutNewline++;
}
final VimStateMachine.Mode mode = VimStateMachine.getInstance(new IjVimEditor(editor)).getMode();
if (mode == VimStateMachine.Mode.VISUAL) {
final Mode mode = VimStateMachine.Companion.getInstance(new IjVimEditor(editor)).getMode();
if (mode instanceof Mode.VISUAL) {
if (closingTagTextRange.getStartOffset() == selectionEndWithoutNewline &&
openingTag.getEndOffset() == selectionStart) {
// 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.LocalMarkStorage
import com.maddyhome.idea.vim.api.SelectionInfo
import com.maddyhome.idea.vim.command.SelectionType
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.state.VimStateMachine
import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.group.visual.VisualChange
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.
*/
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.

View File

@ -33,14 +33,13 @@ import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.VimShortcutKeyAction
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.helper.inNormalMode
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.newapi.globalIjOptions
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.isIdeaRefactorModeKeep
import org.jetbrains.annotations.NonNls
@ -125,9 +124,7 @@ internal object IdeaSpecifics {
) {
editor?.let {
val commandState = it.vim.vimStateMachine
while (commandState.mode != VimStateMachine.Mode.COMMAND) {
commandState.popModes()
}
commandState.mode = Mode.NORMAL()
VimPlugin.getChange().insertBeforeCursor(it.vim, event.dataContext.vim)
KeyHandler.getInstance().reset(it.vim)
}
@ -163,7 +160,7 @@ internal object IdeaSpecifics {
if (!editor.selectionModel.hasSelection()) {
// Enable insert mode if there is no selection in template
// Template with selection is handled by [com.maddyhome.idea.vim.group.visual.VisualMotionGroup.controlNonVimSelectionChange]
if (editor.vim.mode.inNormalMode) {
if (editor.vim.inNormalMode) {
VimPlugin.getChange().insertBeforeCursor(
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.getLineStartForOffset
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.group.EditorGroup
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.exitVisualMode
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.isEndAllowed
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.localEditors
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
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.vimDisabled
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.newapi.IjVimEditor
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.ex.ExEntryPanel
import java.awt.event.MouseAdapter
@ -447,7 +447,7 @@ internal object VimListenerManager {
ExOutputModel.getInstance(editor).clear()
val caretModel = editor.caretModel
if (editor.vim.subMode != VimStateMachine.SubMode.NONE) {
if (editor.vim.mode.selectionType != null) {
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.VimEditor
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.LiveRange
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.VimVisualPosition
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.SelectionType
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.EditorLine
import com.maddyhome.idea.vim.common.IndentConfig
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.fileSize
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.updateCaretsVisualAttributes
import com.maddyhome.idea.vim.helper.updateCaretsVisualPosition
@ -70,7 +71,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
val originalEditor = editor
override val lfMakesNewLine: Boolean = true
override var vimChangeActionSwitchMode: VimStateMachine.Mode?
override var vimChangeActionSwitchMode: Mode?
get() = editor.vimChangeActionSwitchMode
set(value) {
editor.vimChangeActionSwitchMode = value
@ -139,7 +140,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
}
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))
} else {
editor.caretModel.allCarets.map { IjVimCaret(it) }
@ -152,7 +153,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
@Suppress("ideavimRunForEachCaret")
override fun forEachCaret(action: (VimCaret) -> Unit) {
if (editor.vim.inBlockSubMode) {
if (editor.vim.inBlockSelection) {
action(IjVimCaret(editor.caretModel.primaryCaret))
} else {
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.VimscriptFunctionService
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.ex.ExOutputModel
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.put.VimPut
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.undo.VimUndoRedo
import com.maddyhome.idea.vim.vimscript.Executor
@ -197,7 +198,7 @@ internal class IjVimInjector : VimInjectorBase() {
override fun commandStateFor(editor: VimEditor): VimStateMachine {
var res = editor.ij.vimStateMachine
if (res == null) {
res = VimStateMachine(editor)
res = VimStateMachineImpl(editor)
editor.ij.vimStateMachine = 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.visualLineToBufferLine
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.newapi.ij
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.helper.hasBlockOrUnderscoreCaret
import com.maddyhome.idea.vim.helper.hasVisualSelection
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
import com.maddyhome.idea.vim.newapi.ijOptions
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
get() = injector.ijOptions(this).idearefactormode.contains(IjOptionConstants.idearefactormode_keep)
@ -36,16 +38,22 @@ internal object IdeaRefactorModeHelper {
fun correctSelection(editor: Editor) {
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 {
editor.selectionModel.removeSelection()
}
}
if (editor.vim.mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
if (mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
val autodetectedSubmode = VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim)
if (editor.vim.subMode != autodetectedSubmode) {
if (mode.selectionType != autodetectedSubmode) {
// 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.LogicalPosition
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.helper.VimBehaviorDiffers
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_SEARCH_REGISTER
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.jupiter.api.TestInfo
@ -159,9 +160,11 @@ internal object NeovimTesting {
assertEquals(neovimContent, editor.document.text)
}
public fun vimMode() = neovimApi.mode.get().mode
private fun assertMode(editor: Editor) {
val ideavimState = editor.vim.vimStateMachine.toVimNotation()
val neovimState = neovimApi.mode.get().mode
val ideavimState = editor.vim.vimStateMachine.mode.toVimNotation()
val neovimState = vimMode()
assertEquals(neovimState, ideavimState)
}
@ -178,7 +181,7 @@ internal object NeovimTesting {
for (register in VALID_REGISTERS) {
if (register in nonCheckingRegisters) 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 ideavimRegister = vimPluginRegister?.text ?: ""
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 = "")

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.VimPlugin
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.key.CommandNode
import com.maddyhome.idea.vim.key.CommandPartNode
@ -29,7 +29,7 @@ class RegisterActionsTest : VimTestCase() {
fun `test simple action`() {
val before = "I ${c}found 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)
@ -41,7 +41,7 @@ class RegisterActionsTest : VimTestCase() {
}
val before = "I ${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)
}
} finally {
@ -57,7 +57,7 @@ class RegisterActionsTest : VimTestCase() {
fun `test turn plugin off and on`() {
val before = "I ${c}found 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(true)
}
@ -71,7 +71,7 @@ class RegisterActionsTest : VimTestCase() {
fun `test enable twice`() {
val before = "I ${c}found 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(true)
VimPlugin.setEnabled(true)
@ -87,7 +87,7 @@ class RegisterActionsTest : VimTestCase() {
val before = "I ${c}found it in a legendary land"
val after = "I f${c}ound it in a legendary land"
var motionRightAction: ActionBeanClass? = null
doTest("l", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
doTest("l", before, after, Mode.NORMAL()) {
motionRightAction =
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.util.containers.toArray
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.helper.mode
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.newapi.globalIjOptions
import com.maddyhome.idea.vim.newapi.vim
import org.junit.jupiter.params.provider.Arguments
@ -68,7 +68,7 @@ inline fun waitAndAssert(timeInMillis: Int = 1000, condition: () -> Boolean) {
fun waitAndAssertMode(
fixture: CodeInsightTestFixture,
mode: VimStateMachine.Mode,
mode: Mode,
timeInMillis: Int? = null,
) {
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.visualLineToBufferLine
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.VimStateMachine.SubMode
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ExOutputModel.Companion.getInstance
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.TestInputModel
import com.maddyhome.idea.vim.helper.getGuiCursorMode
import com.maddyhome.idea.vim.helper.inBlockSubMode
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.state.mode.inBlockSelection
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.key.MappingOwner
import com.maddyhome.idea.vim.key.ToKeysMappingInfo
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
@ -263,6 +261,13 @@ abstract class VimTestCase {
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 {
fixture.configureByText(fileName, "\n")
NeovimTesting.setupEditor(fixture.editor, testInfo)
@ -393,9 +398,16 @@ abstract class VimTestCase {
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)
assertSubMode(subModeAfter)
assertCaretsVisualAttributes()
}
@ -517,16 +529,11 @@ abstract class VimTestCase {
}
}
fun assertMode(expectedMode: VimStateMachine.Mode) {
fun assertMode(expectedMode: Mode) {
val mode = fixture.editor.vim.mode
assertEquals(expectedMode, mode)
}
fun assertSubMode(expectedSubMode: SubMode) {
val subMode = fixture.editor.vim.subMode
assertEquals(expectedSubMode, subMode)
}
fun assertSelection(expected: String?) {
val selected = fixture.editor.selectionModel.selectedText
assertEquals(expected, selected)
@ -565,7 +572,7 @@ abstract class VimTestCase {
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)
if (caret !== editor.caretModel.primaryCaret && editor.vim.inBlockSubMode) {
if (caret !== editor.caretModel.primaryCaret && editor.vim.inBlockSelection) {
assertEquals(CaretVisualAttributes.Shape.BAR, caret.visualAttributes.shape)
assertEquals(0F, caret.visualAttributes.thickness)
} else {
@ -591,8 +598,7 @@ abstract class VimTestCase {
keys: List<String>,
before: String,
after: String,
modeAfter: VimStateMachine.Mode = VimStateMachine.Mode.COMMAND,
subModeAfter: SubMode = SubMode.NONE,
modeAfter: Mode = Mode.NORMAL(),
fileType: FileType? = null,
fileName: String? = null,
afterEditorInitialized: ((Editor) -> Unit)? = null,
@ -602,7 +608,6 @@ abstract class VimTestCase {
before,
after,
modeAfter,
subModeAfter,
fileType,
fileName,
afterEditorInitialized,
@ -614,8 +619,7 @@ abstract class VimTestCase {
keys: String,
before: String,
after: String,
modeAfter: VimStateMachine.Mode = VimStateMachine.Mode.COMMAND,
subModeAfter: SubMode = SubMode.NONE,
modeAfter: Mode = Mode.NORMAL(),
fileType: FileType? = null,
fileName: String? = null,
afterEditorInitialized: ((Editor) -> Unit)? = null,
@ -628,14 +632,14 @@ abstract class VimTestCase {
configureByText(before)
}
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)
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
assertState(after)
assertState(modeAfter, subModeAfter)
assertState(modeAfter)
}
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.impl.FoldingUtil
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -29,8 +31,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"),
"abc${c}d\n",
"abcd12\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -41,8 +42,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "o", "123", "<Esc>", "x"),
"abc${c}d\n",
"abcd\n12\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -53,8 +53,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v"),
"12${c}345",
"12${s}${c}3${se}45",
VimStateMachine.Mode.INSERT_VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER,
Mode.VISUAL(SelectionType.CHARACTER_WISE, ReturnTo.INSERT)
)
}
@ -65,8 +64,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v", "<esc>"),
"12${c}345",
"12${c}345",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -77,8 +75,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v", "d"),
"12${c}345",
"12${c}45",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -90,8 +87,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "v", "<C-G>"),
"12${c}345",
"12${s}3${c}${se}45",
VimStateMachine.Mode.INSERT_SELECT,
VimStateMachine.SubMode.VISUAL_CHARACTER,
Mode.SELECT(SelectionType.CHARACTER_WISE, ReturnTo.INSERT),
)
}
@ -103,8 +99,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "gh"),
"12${c}345",
"12${s}3${c}${se}45",
VimStateMachine.Mode.INSERT_SELECT,
VimStateMachine.SubMode.VISUAL_CHARACTER,
Mode.SELECT(SelectionType.CHARACTER_WISE, ReturnTo.INSERT),
)
}
@ -116,8 +111,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "gh", "<esc>"),
"12${c}345",
"123${c}45",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -130,8 +124,7 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "<C-O>", "gh", "d"),
"12${c}345",
"12d${c}45",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -142,32 +135,31 @@ class ChangeActionTest : VimTestCase() {
listOf("i", "def", "<C-O>", "d2h", "x"),
"abc$c.\n",
"abcdx.\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
// VIM-321 |d| |count|
@Test
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 |~|
@Test
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 |~|
@Test
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
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
@ -176,14 +168,13 @@ class ChangeActionTest : VimTestCase() {
"gUw",
"${c}FooBar Baz\n",
"FOOBAR Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@Test
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
@ -192,8 +183,7 @@ class ChangeActionTest : VimTestCase() {
"ve~",
"${c}FooBar Baz\n",
"fOObAR Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -203,8 +193,7 @@ class ChangeActionTest : VimTestCase() {
"veU",
"${c}FooBar Baz\n",
"FOOBAR Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -214,8 +203,7 @@ class ChangeActionTest : VimTestCase() {
"veu",
"${c}FooBar Baz\n",
"foobar Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -236,8 +224,7 @@ class ChangeActionTest : VimTestCase() {
four
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -256,8 +243,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
assertOffset(4)
}
@ -277,8 +263,7 @@ class ChangeActionTest : VimTestCase() {
three
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -299,8 +284,7 @@ class ChangeActionTest : VimTestCase() {
three
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -315,8 +299,7 @@ class ChangeActionTest : VimTestCase() {
"""one
three
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
assertOffset(3)
}
@ -332,8 +315,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(),
"one four\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -344,8 +326,7 @@ class ChangeActionTest : VimTestCase() {
"d2w",
"on${c}e two three\n",
"on${c}three\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -360,8 +341,7 @@ class ChangeActionTest : VimTestCase() {
"""foo
, baz
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -380,8 +360,7 @@ class ChangeActionTest : VimTestCase() {
baz
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -400,8 +379,7 @@ class ChangeActionTest : VimTestCase() {
bar
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
assertOffset(1)
}
@ -417,8 +395,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(),
"two\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -430,8 +407,7 @@ class ChangeActionTest : VimTestCase() {
listOf("A", ", ", "<C-R>", "a", "!"),
"${c}Hello\n",
"Hello, World!\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -442,8 +418,7 @@ class ChangeActionTest : VimTestCase() {
listOf("O", "bar"),
"fo${c}o\n",
"bar\nfoo\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -454,8 +429,7 @@ class ChangeActionTest : VimTestCase() {
listOf("v", "k\$d"),
"foo\n${c}bar\n",
"fooar\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -478,8 +452,7 @@ class ChangeActionTest : VimTestCase() {
quux
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -501,8 +474,7 @@ class ChangeActionTest : VimTestCase() {
quux
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -518,8 +490,7 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -535,8 +506,7 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -551,8 +521,7 @@ quux
bar
""".dotToSpace().trimIndent(),
"foo bar",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -565,8 +534,7 @@ quux
bar
""".dotToSpace().trimIndent(),
"foo bar",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -582,8 +550,7 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -599,8 +566,7 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -610,8 +576,7 @@ quux
listOf("<C-V>", "x"),
"fo${c}o\n",
"fo\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -624,8 +589,7 @@ quux
listOf("<C-V>", "j", "x"),
"\n\n",
"\n\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -646,8 +610,7 @@ quux
br
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -669,8 +632,7 @@ quux
br
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -697,20 +659,20 @@ quux
// |r|
@Test
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|
@VimBehaviorDiffers(originalVimAfter = "foXX${c}Xr\n")
@Test
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|
@Test
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|
@ -729,8 +691,7 @@ quux
ZZZZZz
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -746,8 +707,7 @@ foobaz
bar
foobaz
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -764,15 +724,14 @@ foobaz
r
foobaz
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
// |s|
@Test
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|
@ -782,8 +741,7 @@ foobaz
"3sxy<Esc>",
"fo${c}obar\n",
"fox${c}yr\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -802,15 +760,14 @@ foobaz
biff
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
// |R|
@Test
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>|
@ -821,8 +778,7 @@ foobaz
"RXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n",
"aaaXXXYYYZZ${c}Zddd\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -834,8 +790,7 @@ foobaz
"iXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n",
"aaaXXXYYYZZ${c}Zcccddd\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -855,8 +810,7 @@ foobaz
fo${c}o quux
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1074,8 +1028,7 @@ and some text after""",
"fXcfYPATATA<Esc>fX.;.",
"${c}aaaaXBBBBYaaaaaaaXBBBBYaaaaaaXBBBBYaaaaaaaa\n",
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1083,10 +1036,10 @@ and some text after""",
fun testRepeatReplace() {
configureByText("${c}foobarbaz spam\n")
typeText(injector.parser.parseKeys("R"))
assertMode(VimStateMachine.Mode.REPLACE)
assertMode(Mode.REPLACE)
typeText(injector.parser.parseKeys("FOO" + "<Esc>" + "l" + "2."))
assertState("FOOFOOFO${c}O spam\n")
assertMode(VimStateMachine.Mode.COMMAND)
assertMode(Mode.NORMAL())
}
@Test
@ -1101,8 +1054,7 @@ and some text after""",
psum dolor sit amet
${c}Lorem Ipsumm dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1118,8 +1070,7 @@ and some text after""",
ipsum dolor sit amet
${c}Lorem Ipsumm dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1135,8 +1086,7 @@ and some text after""",
ipsum dolor sit amet
${c}Lorem Ipsumm dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1152,8 +1102,7 @@ and some text after""",
ipsum dolor sit amet
${c}Lorem Ipsumm dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1169,8 +1118,7 @@ and some text after""",
${c}Lorem Ipsumm dolor sit amet
psum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1186,8 +1134,7 @@ and some text after""",
${c}Lorem Ipsumm dolor sit amet
ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1206,8 +1153,7 @@ and some text after""",
${c}lorem ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1227,8 +1173,7 @@ and some text after""",
gaganis ${c}gaganis gaganis
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -1245,8 +1190,7 @@ and some text after""",
line 1
${c}line 3
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ import com.intellij.idea.TestFor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
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.helper.VimBehaviorDiffers
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.api.injector
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -26,7 +26,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "<C-\\><C-N>"
val before = "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())
}
@ -35,7 +35,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>")
val before = "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())
}
@ -44,7 +44,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>")
val before = "A Disc${c}overy"
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())
}
@ -53,7 +53,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>", "3l")
val before = "${c}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())
}
@ -62,7 +62,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("V", "<C-\\><C-N>")
val before = "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())
}
@ -71,7 +71,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("gH", "<C-\\><C-N>")
val before = "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())
}
@ -80,7 +80,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-\\><C-N>")
val before = "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())
}
@ -89,7 +89,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "d<Esc>dw"
val before = "Lorem 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())
}
@ -98,7 +98,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-\\><C-N>", "dw")
val before = "Lorem 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())
}
@ -107,7 +107,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<Esc>", "dw")
val before = "Lorem 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())
}
@ -117,7 +117,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-[>", "dw")
val before = "Lorem 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())
}
@ -136,7 +136,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-D>", "dw")
val before = "Lorem 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())
}
@ -145,7 +145,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("c", "<C-\\><C-N>", "another")
val before = "Lorem 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())
}
@ -154,7 +154,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "dt<esc>D"
val before = "A ${c}Discovery"
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())
}
}

View File

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

View File

@ -8,7 +8,7 @@
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.junit.jupiter.api.Test
@ -25,7 +25,7 @@ class UndoActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
val after = before
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
val editor = fixture.editor
kotlin.test.assertFalse(editor.caretModel.primaryCaret.hasSelection())
}
@ -42,7 +42,7 @@ class UndoActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
val after = before
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(hasSelection())
}
@ -65,7 +65,7 @@ class UndoActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(hasSelection())
}
@ -89,7 +89,7 @@ class UndoActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
kotlin.test.assertFalse(hasSelection())
}
}

View File

@ -8,7 +8,7 @@
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.junit.jupiter.api.Test
@ -18,7 +18,7 @@ class ChangeLineActionTest : VimTestCase() {
setupChecks {
this.neoVim.ignoredRegisters = setOf('1', '"')
}
doTest("cc", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("cc", "", "", Mode.INSERT)
}
@Test
@ -26,7 +26,7 @@ class ChangeLineActionTest : VimTestCase() {
setupChecks {
this.neoVim.ignoredRegisters = setOf('1', '"')
}
doTest("S", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("S", "", "", Mode.INSERT)
}
@Test
@ -41,8 +41,7 @@ class ChangeLineActionTest : VimTestCase() {
Lorem ipsum dolor sit amet,
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -60,8 +59,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -77,8 +75,7 @@ class ChangeLineActionTest : VimTestCase() {
Lorem ipsum dolor sit amet,
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -96,8 +93,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -113,8 +109,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
consectetur adipiscing elit
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -132,8 +127,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -151,8 +145,7 @@ class ChangeLineActionTest : VimTestCase() {
consectetur adipiscing elit
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -190,8 +183,7 @@ class ChangeLineActionTest : VimTestCase() {
that priceless mote now dimpling the convex
and limpid teardrop on a lighted slide.
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
}

View File

@ -10,7 +10,7 @@
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.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
@ -19,13 +19,13 @@ class ChangeMotionActionTest : VimTestCase() {
// VIM-515 |c| |W|
@Test
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|
@Test
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|
@ -35,8 +35,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cc",
"foo\n" + "${c}bar\n",
"foo\n${c}" + "\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -55,8 +54,7 @@ class ChangeMotionActionTest : VimTestCase() {
....${c}
}
""".trimIndent().dotToSpace(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -67,8 +65,7 @@ class ChangeMotionActionTest : VimTestCase() {
"ccbaz",
"${c}foo\n" + "bar\n",
"baz\n" + "bar\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -86,8 +83,7 @@ class ChangeMotionActionTest : VimTestCase() {
${c}
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -97,8 +93,7 @@ class ChangeMotionActionTest : VimTestCase() {
"c_baz",
"${c}foo\n" + "bar\n",
"baz\n" + "bar\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -109,8 +104,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cw",
"on${c}e two three\n",
"on${c} two three\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -121,8 +115,7 @@ class ChangeMotionActionTest : VimTestCase() {
"c2w",
"on${c}e two three\n",
"on${c} three\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -141,8 +134,7 @@ class ChangeMotionActionTest : VimTestCase() {
}
""".trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -153,8 +145,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cT(",
"if (condition) ${c}{\n" + "}\n",
"if ({\n" + "}\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -167,8 +158,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cFc",
"if (condition) {${c}\n" + "}\n",
"if (\n" + "}\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -179,8 +169,7 @@ class ChangeMotionActionTest : VimTestCase() {
"cw",
"ab.${c}cd\n",
"ab.${c}\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
@ -191,19 +180,18 @@ class ChangeMotionActionTest : VimTestCase() {
listOf("c", "iw", "baz"),
"foo bar bo${c}o\n",
"foo bar baz\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
// VIM-421 |c| |w|
@Test
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
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
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 org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
@ -35,7 +35,7 @@ class ChangeVisualActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -56,7 +56,7 @@ class ChangeVisualActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.INSERT)
}
@VimBehaviorDiffers(
@ -89,7 +89,7 @@ class ChangeVisualActionTest : VimTestCase() {
${c}
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.INSERT)
}
@Test
@ -116,7 +116,7 @@ class ChangeVisualActionTest : VimTestCase() {
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.INSERT)
}
@VimBehaviorDiffers(description = "Wrong caret position")
@ -139,7 +139,7 @@ class ChangeVisualActionTest : VimTestCase() {
wh|Hello
ha|Hello
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -147,7 +147,7 @@ class ChangeVisualActionTest : VimTestCase() {
val keys = "VcHello<esc>"
val before = "${c}Lorem Ipsum"
val after = "Hello"
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -156,7 +156,7 @@ class ChangeVisualActionTest : VimTestCase() {
injector.parser.parseKeys("v2lc" + "aaa" + "<ESC>"),
"abcd${c}ffffff${c}abcde${c}aaaa\n",
)
assertMode(VimStateMachine.Mode.COMMAND)
assertMode(Mode.NORMAL())
assertState("abcdaa${c}afffaa${c}adeaa${c}aa\n")
}
@ -178,8 +178,7 @@ class ChangeVisualActionTest : VimTestCase() {
ba_quux_bar
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -201,8 +200,7 @@ class ChangeVisualActionTest : VimTestCase() {
ba_quux_bar
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

@ -10,7 +10,7 @@
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 org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
@ -35,7 +35,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
Sed in orci mauris.
${c}
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.INSERT)
}
@Test
@ -59,7 +59,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas.
${c}
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.INSERT)
}
@VimBehaviorDiffers(
@ -93,6 +93,6 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
${c}
""".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
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
@ -38,6 +38,6 @@ class InsertRegisterTest : VimTestCase() {
all rocks and lavender and tufted grass,
$c
""".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
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
class ChangeNumberDecActionTest : VimTestCase() {
@Test
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
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
@ -29,14 +29,13 @@ class ChangeNumberDecActionTest : VimTestCase() {
":set nrformats+=octal<CR><C-X>",
"00000",
"01777777777777777777777",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@Test
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
@ -45,8 +44,7 @@ class ChangeNumberDecActionTest : VimTestCase() {
":set nrformats+=octal<CR>10<C-X>",
"00005",
"01777777777777777777773",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

@ -8,7 +8,7 @@
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 org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
@ -17,6 +17,6 @@ class ChangeNumberIncActionTest : VimTestCase() {
@VimBehaviorDiffers(originalVimAfter = "11X0")
@Test
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
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
@ -30,8 +30,7 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1
number 1
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -49,8 +48,7 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1
number 1
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

@ -8,7 +8,7 @@
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.junit.jupiter.api.Test
@ -30,8 +30,7 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 3
number 4
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -49,8 +48,7 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 5
number 7
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

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

View File

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

View File

@ -8,7 +8,7 @@
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.junit.jupiter.api.Test
@ -29,8 +29,7 @@ class DeleteEndOfLineActionTest : VimTestCase() {
Lorem ipsum dolor sit amet,
consectetur adipiscing elit
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

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

View File

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

View File

@ -9,7 +9,8 @@
package org.jetbrains.plugins.ideavim.action.change.delete
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -40,7 +41,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -62,7 +63,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -84,7 +85,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -106,7 +107,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@ -125,7 +126,7 @@ class DeleteVisualActionTest : VimTestCase() {
""".trimIndent(),
)
IdeaSelectionControl.controlNonVimSelectionChange(fixture.editor)
waitAndAssertMode(fixture, VimStateMachine.Mode.VISUAL)
waitAndAssertMode(fixture, Mode.VISUAL(SelectionType.LINE_WISE))
typeText(injector.parser.parseKeys("d"))
assertState(
"""
@ -134,7 +135,7 @@ class DeleteVisualActionTest : VimTestCase() {
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
)
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
assertState(Mode.NORMAL())
}
@Test
@ -156,6 +157,6 @@ class DeleteVisualActionTest : VimTestCase() {
wh|
ha|
""".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
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
@ -30,8 +30,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -50,8 +49,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
consectetur adipiscing elit
${c}Sed in orci mauris.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -70,8 +68,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -90,8 +87,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
consectetur adipiscing elit
${c}Sed in orci mauris.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -114,7 +110,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
consectetur adipiscing elit
${c}
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -138,6 +134,6 @@ class DeleteVisualLinesActionTest : VimTestCase() {
${c}
""".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
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.options.OptionConstants
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -674,7 +674,7 @@ class DeleteVisualLinesEndActionTest : VimTestCase() {
Today it is not working
The test is like that.
""".trimIndent(),
VimStateMachine.Mode.INSERT,
Mode.INSERT,
)
}
}

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert
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.junit.jupiter.api.Test
@ -53,9 +53,8 @@ class InsertAfterLineEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
assertMode(VimStateMachine.Mode.COMMAND)
assertMode(Mode.NORMAL())
}
}

View File

@ -8,14 +8,14 @@
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.junit.jupiter.api.Test
class InsertBeforeCursorActionTest : VimTestCase() {
@Test
fun `test check caret shape`() {
doTest("i", "123", "123", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("i", "123", "123", Mode.INSERT)
assertCaretsVisualAttributes()
}
}

View File

@ -8,7 +8,7 @@
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.junit.jupiter.api.Test
@ -33,9 +33,8 @@ class InsertBeforeFirstNonBlankActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
assertMode(VimStateMachine.Mode.COMMAND)
assertMode(Mode.NORMAL())
}
}

View File

@ -8,7 +8,7 @@
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 org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
@ -29,8 +29,7 @@ class InsertDeleteInsertedTextActionTest : VimTestCase() {
I found iti${c}t in a legendary land
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -50,8 +49,7 @@ class InsertDeleteInsertedTextActionTest : VimTestCase() {
I found ii${c}ta legendary land
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

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

View File

@ -8,7 +8,7 @@
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.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@ -28,7 +28,7 @@ class InsertEnterActionTest : VimTestCase() {
|Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas.
""".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)
@ -45,7 +45,7 @@ class InsertEnterActionTest : VimTestCase() {
|Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas.
""".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)

View File

@ -8,18 +8,18 @@
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.junit.jupiter.api.Test
class InsertExitModeActionTest : VimTestCase() {
@Test
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
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
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.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@ -28,7 +28,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas.
""".trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("O", before, after, Mode.INSERT)
}
@Test
@ -44,7 +44,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|where it was settled on some sodden sand
|hard by the torrent of a mountain pass.
""".trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("O", before, after, Mode.INSERT)
}
@Test
@ -60,7 +60,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
| Sed in orci mauris.
| Cras id tellus in ex imperdiet egestas.
""".trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("O", before, after, Mode.INSERT)
}
@Test
@ -76,7 +76,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
| Sed in orci mauris.
| Cras id tellus in ex imperdiet egestas.
""".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
@ -114,7 +114,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
| $c
| hard by the torrent of a mountain pass.
""".trimMargin()
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("O", before, after, Mode.INSERT)
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -142,6 +142,6 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|Sed in orci mauris.
|Cras id tellus in ex imperdiet egestas.
""".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
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.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@ -28,7 +28,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|where it was settled on some sodden sand
|hard by the torrent of a mountain pass.
""".trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("o", before, after, Mode.INSERT)
}
@Test
@ -44,7 +44,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|where it was settled on some sodden sand
|hard by the torrent of a mountain pass.
""".trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("o", before, after, Mode.INSERT)
}
@Test
@ -60,7 +60,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
| where it was settled on some sodden sand
| hard by the torrent of a mountain pass.
""".trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("o", before, after, Mode.INSERT)
}
@Test
@ -76,7 +76,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
| where it was settled on some sodden sand
| hard by the torrent of a mountain pass.
""".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
@ -133,7 +133,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
| hard by the torrent of a mountain pass.
| $c
""".trimMargin()
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("o", before, after, Mode.INSERT)
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -160,7 +160,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|where it was settled on some sodden sand
|hard by the torrent of a mountain pass.
""".trimMargin()
doTest("5o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest("5o", before, after, Mode.INSERT)
}
@Test
@ -199,7 +199,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
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")
@ -219,7 +219,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
configureAndFold(before, "")
performTest("o", after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
performTest("o", after, Mode.INSERT)
}
@Test
@ -238,6 +238,6 @@ class InsertNewLineBelowActionTest : VimTestCase() {
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
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
@ -19,8 +19,7 @@ class InsertSingleCommandActionTest : VimTestCase() {
listOf("i", "<C-O>", "vlll", "<Esc>"),
"I found ${c}it in a legendary land",
"I found it ${c}in a legendary land",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
}

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert
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.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@ -70,9 +70,8 @@ class VisualBlockAppendActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
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.impl.FoldingUtil
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.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@ -200,8 +200,7 @@ Xbar
listOf("<C-V>", "lll", "I"),
before.trimIndent(),
before.trimIndent(),
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
Mode.INSERT,
)
}
}

View File

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

View File

@ -9,7 +9,7 @@
package org.jetbrains.plugins.ideavim.action.copy
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 org.jetbrains.plugins.ideavim.VimTestCase
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.maddyhome.idea.vim.VimPlugin
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.options.OptionConstants
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.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.newapi.vim
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.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.helper.VimBehaviorDiffers
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.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.newapi.vim
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.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.junit.jupiter.api.Test
@ -57,7 +57,7 @@ class YankVisualLinesActionTest : VimTestCase() {
${c}where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest("vjY", text, textAfter, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest("vjY", text, textAfter, Mode.NORMAL())
val yankedTest = """
where it was settled on some sodden sand
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.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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -79,8 +79,7 @@ class GnNextTextObjectTest : VimTestCase() {
listOf("/is<CR>", ":s/test/tester/<CR>", "0", "dgn"),
"Hello, ${c}this is a test here",
"Hello, this is a ${c}er here",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -89,6 +88,6 @@ class GnNextTextObjectTest : VimTestCase() {
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
typeText(keys)
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.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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -57,8 +57,7 @@ class GnPreviousTextObjectTest : VimTestCase() {
listOf("/is<CR>", ":s/test/tester/<CR>", "$", "dgN"),
"Hello, ${c}this is a test here",
"Hello, this is a ${c}er here",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -67,6 +66,6 @@ class GnPreviousTextObjectTest : VimTestCase() {
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
typeText(keys)
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.action.motion.search.SearchWholeWordForwardAction
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
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")
assertOffset(16)
assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -37,7 +38,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
"h<caret>ello world\nh<caret>ello world hello world",
)
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -49,7 +50,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
)
assertOffset(0)
assertSelection("h")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
@ -60,7 +61,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeText(injector.parser.parseKeys("gn"))
assertOffset(7)
assertSelection("test")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -69,7 +70,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gn"), "h<caret>ello world\nhello world hello world")
assertOffset(16)
assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@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")
assertOffset(28)
assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -109,7 +110,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
)
assertOffset(28)
assertSelection(null)
assertMode(VimStateMachine.Mode.COMMAND)
assertMode(Mode.NORMAL())
}
@Test
@ -125,7 +126,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*0e" + "gn"), "h<caret>ello hello")
assertOffset(4)
assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -134,7 +135,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*0llv" + "gn"), "h<caret>ello hello")
assertOffset(4)
assertSelection("llo")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -143,7 +144,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*0ev" + "gn"), "h<caret>ello hello")
assertOffset(10)
assertSelection("o hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -155,7 +156,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
)
assertOffset(28)
assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -167,7 +168,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
)
assertOffset(28)
assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@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.action.motion.search.SearchWholeWordForwardAction
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
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")
assertOffset(12)
assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -37,7 +38,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
"h<caret>ello world\nh<caret>ello world hello world",
)
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -46,7 +47,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gN"), "h<caret>ello world\nhello world hello world")
assertOffset(12)
assertSelection("hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
@ -57,7 +58,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeText(injector.parser.parseKeys("gN"))
assertOffset(0)
assertSelection("test")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -74,7 +75,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN"), "hello world\nh<caret>ello world hello")
assertOffset(12)
assertSelection("hello world hello")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@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")
assertOffset(12)
assertSelection(null)
assertMode(VimStateMachine.Mode.COMMAND)
assertMode(Mode.NORMAL())
}
@TestFor(classes = [SearchWholeWordForwardAction::class])
@ -92,7 +93,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("*llv" + "gN"), "hello hello")
assertOffset(6)
assertSelection("hel")
assertMode(VimStateMachine.Mode.VISUAL)
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@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")
assertOffset(18)
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
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -247,8 +248,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER,
Mode.VISUAL(SelectionType.CHARACTER_WISE),
)
}
@ -273,8 +273,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -299,8 +298,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER,
Mode.VISUAL(SelectionType.CHARACTER_WISE),
)
}
@ -325,8 +323,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -351,8 +348,7 @@ class MotionArrowLeftActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}

View File

@ -11,7 +11,8 @@
package org.jetbrains.plugins.ideavim.action.motion.leftright
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -205,8 +206,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER,
Mode.VISUAL(SelectionType.CHARACTER_WISE),
)
}
@ -231,8 +231,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -257,8 +256,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER,
Mode.VISUAL(SelectionType.CHARACTER_WISE),
)
}
@ -283,8 +281,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -309,8 +306,7 @@ class MotionArrowRightActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}

View File

@ -10,7 +10,8 @@
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -42,7 +43,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -65,7 +66,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
doTest(keys, before, after, Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -88,7 +89,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER)
doTest(keys, before, after, Mode.SELECT(SelectionType.CHARACTER_WISE))
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -111,7 +112,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -134,7 +135,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -157,7 +158,7 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@TestWithoutNeovim(SkipNeovimReason.NON_ASCII)
@ -180,6 +181,6 @@ class MotionEndActionTest : VimTestCase() {
Sed in orci mauris.
Cras id tellus in ex imperdiet egestas.
""".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
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestOptionConstants
@ -43,7 +44,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@OptionTest(VimOption(TestOptionConstants.keymodel, doesntAffectTest = true))
@ -72,7 +73,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
doTest(keys, before, after, Mode.VISUAL(SelectionType.CHARACTER_WISE))
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -95,7 +96,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER)
doTest(keys, before, after, Mode.SELECT(SelectionType.CHARACTER_WISE))
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -118,7 +119,7 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@ -141,6 +142,6 @@ class MotionHomeActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".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
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 org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -37,7 +38,7 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -59,7 +60,7 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.NORMAL())
}
@Test
@ -81,7 +82,7 @@ class MotionLastColumnActionTest : VimTestCase() {
wh${s}ere it was settled on some sodden sand${c}${se}
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
doTest(keys, before, after, Mode.VISUAL(SelectionType.BLOCK_WISE))
}
@Test
@ -136,7 +137,7 @@ class MotionLastColumnActionTest : VimTestCase() {
wh${s}ere it was settled on some sodden san${c}d${se}
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
doTest(keys, before, after, Mode.VISUAL(SelectionType.BLOCK_WISE))
}
@Test
@ -158,7 +159,7 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
doTest(keys, before, after, Mode.INSERT)
}
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
@ -181,6 +182,6 @@ class MotionLastColumnActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".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
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.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@ -26,7 +26,7 @@ class MotionLeftInsertTest : VimTestCase() {
"""
Oh, hi M${c}ark
""".trimIndent(),
VimStateMachine.Mode.INSERT,
Mode.INSERT,
) {
enterCommand("set whichwrap=[")
}
@ -43,7 +43,7 @@ class MotionLeftInsertTest : VimTestCase() {
"""
${c}Oh, hi Mark
""".trimIndent(),
VimStateMachine.Mode.INSERT,
Mode.INSERT,
) {
enterCommand("set whichwrap=[")
}
@ -62,7 +62,7 @@ class MotionLeftInsertTest : VimTestCase() {
Oh, hi Mark$c
You are my favourite customer
""".trimIndent(),
VimStateMachine.Mode.INSERT,
Mode.INSERT,
) {
enterCommand("set whichwrap=[")
}
@ -85,7 +85,7 @@ class MotionLeftInsertTest : VimTestCase() {
You are my favourite customer
""".trimIndent(),
VimStateMachine.Mode.INSERT,
Mode.INSERT,
) {
enterCommand("set whichwrap=[")
}

View File

@ -8,7 +8,7 @@
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.junit.jupiter.api.Test
@ -19,8 +19,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx;",
"hello x hello x hello$c",
"hello ${c}x hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -30,8 +29,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx;;",
"hello x hello x hello x hello$c",
"hello ${c}x hello x hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -41,8 +39,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx2;",
"hello x hello x hello x hello$c",
"hello ${c}x hello x hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -52,8 +49,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
"Fx3;",
"hello x hello x hello x hello x hello$c",
"hello ${c}x hello x hello x hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

View File

@ -8,7 +8,7 @@
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.junit.jupiter.api.Test
@ -19,8 +19,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx;",
"hello x hello x hello$c",
"hello x$c hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -30,8 +29,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx;;",
"hello x hello x hello x hello$c",
"hello x$c hello x hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -41,8 +39,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx2;",
"hello x hello x hello x hello$c",
"hello x hello x$c hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
@ -52,8 +49,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
"Tx3;",
"hello x hello x hello x hello$c",
"hello x$c hello x hello x hello",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
Mode.NORMAL(),
)
}
}

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