1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-18 01:31:44 +02:00

Compare commits

..

47 Commits

Author SHA1 Message Date
edb9b194bb Set plugin version to chylex-12 2022-07-06 01:15:57 +02:00
Alex Plate
eae7ed95e2 Revert "Fix(VIM-308) Undo requires one more step if the cursor is not at the position where it was after undo"
This reverts commit 9dbe3c33
2022-07-06 01:15:56 +02:00
a1e2ae0eb9 Change matchit plugin to use HTML patterns in unrecognized files 2022-07-06 01:15:56 +02:00
eae2e3b6b8 Fix put command not working with multiple cursors 2022-07-06 01:15:56 +02:00
c2d997a520 Fix vim-surround not working with multiple cursors
Fixes multiple cursors with vim-surround commands `cs, ds, S` (but not `ys`).
2022-07-06 01:15:56 +02:00
e2a8a3c21a Add VimScript 'renaming()' function 2022-07-06 01:08:14 +02:00
9b7fee6163 Add support for repeatable actions with ':raction' 2022-07-06 01:08:14 +02:00
d0f9d3dc70 Implement partial code completion support in macros
Works ok with insertions (Enter, Ctrl+Enter) but not with replacements (Tab)
2022-07-06 01:08:14 +02:00
8d3a69b338 Disable taking over arrow keys and Home/End 2022-07-06 01:08:14 +02:00
3c530474a1 Set custom plugin version 2022-07-06 01:08:14 +02:00
filipp
bfd0b5fd91 Merge remote-tracking branch 'origin/master' 2022-07-02 11:21:33 +06:00
Alex Plate
6c0a52155b Add compatibility method 2022-07-01 16:36:30 +03:00
Alex Plate
c7ebce39bf Make options compatible 2022-07-01 16:10:13 +03:00
Alex Plate
a0dc7a792f Add more compatibility methods 2022-07-01 15:55:07 +03:00
Alex Plate
fdb09a8f1f Use vim-engine kotlin settings 2022-07-01 12:18:53 +03:00
Alex Plate
4ac2aa2339 Apply kotlin options to all projects 2022-07-01 11:29:15 +03:00
Alex Plate
ebbc20692a Add JVM compatibility option to the compiler 2022-07-01 10:58:32 +03:00
Alex Plate
5c82d112c9 More compatibility methods 2022-07-01 10:05:13 +03:00
Alex Plate
40fd50d7f1 Add midding import 2022-07-01 09:27:07 +03:00
Alex Plate
f7b948fee2 Add CommandState compatibility layer and rename our main CommandState to VimStateMachine 2022-07-01 09:04:27 +03:00
Alex Plate
6cdcf133bb Use snapshot version of gradle plugin 2022-06-30 09:14:29 +03:00
filipp
f3025757b6 Merge remote-tracking branch 'origin/master' 2022-06-30 11:02:41 +06:00
nikita.koshcheev
a49811a3f9 TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: Updated cloud profile 'amazon-48' in project 'project55' 2022-06-29 15:16:26 +00:00
Alex Plate
2ac4b265d1 Add compatibility method 2022-06-29 16:30:26 +03:00
Alex Plate
46e994b563 Fix incorrect inheritance 2022-06-29 11:42:21 +03:00
Alex Plate
81482bd298 Add more compatibility changes 2022-06-29 11:25:11 +03:00
Alex Plate
f1a239c085 Make compatibility function public 2022-06-29 10:42:04 +03:00
Alex Plate
a48e38de7b Make function static 2022-06-29 10:25:41 +03:00
Alex Plate
0aaacee117 Add more classes for compatibility 2022-06-29 09:54:50 +03:00
Alex Plate
b8373af69f Move MappingMode to a different package 2022-06-29 09:54:49 +03:00
Alex Plate
e99b2ee73d Add new method for compatibility 2022-06-29 09:54:49 +03:00
aleksei.plate
705022331a TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: general settings of 'IdeaVim compatibility with external plugins' build configuration were updated 2022-06-28 08:48:58 +00:00
aleksei.plate
bf62d444bf TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: general settings of 'IdeaVim compatibility with external plugin' build configuration were updated 2022-06-28 08:47:35 +00:00
aleksei.plate
5dcff5657b TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: general settings of 'IdeaVim compativility with external plugin' build configuration were updated 2022-06-28 08:47:11 +00:00
Alex Plate
7e79d5a960 Add method for compatibility 2022-06-28 11:13:54 +03:00
Alex Plate
c1b480976d Include source files into distribution 2022-06-28 11:13:54 +03:00
Alex Plate
ddabbe6891 Use vim-engine as API instead of implementation 2022-06-28 11:13:54 +03:00
Alex Plate
ffa3052b50 Update build version of IJ 2022-06-28 11:13:54 +03:00
Alex Plate
654ea88851 Add collecting of sources to the resulting jar 2022-06-28 11:13:54 +03:00
filipp
4dc7982baa (EA-480768) Better exception message 2022-06-27 16:19:45 +06:00
aleksei.plate
ae2fc1cd85 TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: runners of 'Build' build configuration were updated 2022-06-27 06:17:38 +00:00
aleksei.plate
78bc8666e6 TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: build features of 'Build' build configuration were updated 2022-06-27 06:16:33 +00:00
aleksei.plate
9c2de2cfc7 TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: build configuration was created from URL 2022-06-27 06:16:18 +00:00
aleksei.plate
71e81465f3 TeamCity change in 'IntelliJ IDEA plugins / IdeaVim' project: 'IdeaVimCompatibility' VCS root was created 2022-06-27 06:15:35 +00:00
Alex Plate
885031e086 Fix test class without test methods 2022-06-27 07:59:22 +03:00
Alex Plate
d77c5bb5cf Update formatting 2022-06-26 00:20:17 +00:00
Alex Plate
781bce0000 Update changelog 2022-06-24 05:27:52 +00:00
270 changed files with 3644 additions and 2883 deletions

View File

@@ -13,7 +13,11 @@ object Constants {
const val PROPERTY_TESTS = "LATEST-EAP-SNAPSHOT"
const val LONG_RUNNING_TESTS = "LATEST-EAP-SNAPSHOT"
const val QODANA_TESTS = "LATEST-EAP-SNAPSHOT"
const val RELEASE = "2021.3"
const val RELEASE_DEV = "LATEST-EAP-SNAPSHOT"
const val RELEASE_EAP = "LATEST-EAP-SNAPSHOT"
const val RELEASE = "2022.1.3"
// Use LATEST-EAP-SNAPSHOT only when we'll update the minimum version of IJ to 222+
// Because of some API inconcistincies, IdeaVim built on 2022+ won't run on older versions of IJ
const val RELEASE_DEV = "2022.1.3"
const val RELEASE_EAP = "2022.1.3"
}

40
.teamcity/patches/buildTypes/Build.kts vendored Normal file
View File

@@ -0,0 +1,40 @@
package patches.buildTypes
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType
import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.golang
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs
import jetbrains.buildServer.configs.kotlin.v2019_2.ui.*
/*
This patch script was generated by TeamCity on settings change in UI.
To apply the patch, create a buildType with id = 'Build'
in the root project, and delete the patch script.
*/
create(DslContext.projectId, BuildType({
id("Build")
name = "IdeaVim compatibility with external plugins"
vcs {
root(RelativeId("HttpsGithubComAlexPl292IdeaVimCompatibilityRefsHeadsMaster"))
}
steps {
script {
scriptContent = "go run test.go"
}
}
triggers {
vcs {
}
}
features {
golang {
testFormat = "json"
}
}
}))

View File

@@ -16,17 +16,12 @@ changeBuildType(RelativeId("Qodana")) {
expectSteps {
qodana {
name = "Qodana"
reportAsTests = true
inspectionProfile = customProfile {
path = ".idea/inspectionProfiles/Qodana.xml"
}
param("clonefinder-enable", "true")
param("clonefinder-languages", "Java")
param("clonefinder-languages-container", "Java Kotlin")
param("clonefinder-mode", "")
param("clonefinder-queried-project", "src")
param("clonefinder-reference-projects", "src")
param("fail-build-on-errors", "")
param("licenseaudit-enable", "true")
param("namesAndTagsCustom", "repo.labs.intellij.net/static-analyser/qodana")
param("report-version", "")

74
.teamcity/patches/projects/_Self.kts vendored Normal file
View File

@@ -0,0 +1,74 @@
package patches.projects
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.AmazonEC2CloudImage
import jetbrains.buildServer.configs.kotlin.v2019_2.AmazonEC2CloudProfile
import jetbrains.buildServer.configs.kotlin.v2019_2.Project
import jetbrains.buildServer.configs.kotlin.v2019_2.amazonEC2CloudImage
import jetbrains.buildServer.configs.kotlin.v2019_2.amazonEC2CloudProfile
import jetbrains.buildServer.configs.kotlin.v2019_2.ui.*
/*
This patch script was generated by TeamCity on settings change in UI.
To apply the patch, change the root project
accordingly, and delete the patch script.
*/
changeProject(DslContext.projectId) {
features {
val feature1 = find<AmazonEC2CloudImage> {
amazonEC2CloudImage {
id = "PROJECT_EXT_768"
profileId = "amazon-48"
agentPoolId = "41"
name = "BuildAgentsIdeaVim"
vpcSubnetId = "subnet-58839511"
keyPairName = ""
instanceType = "c5d.xlarge"
securityGroups = listOf("sg-eda08696", "sg-7332cf0f")
useSpotInstances = true
instanceTags = mapOf(
"project" to "idea-vim"
)
source = Source("ami-0d1a6a32faa92923e")
param("image-instances-limit", "")
param("spot-instance-price", "")
}
}
feature1.apply {
profileId = "amazon-48"
agentPoolId = "41"
name = "BuildAgentsIdeaVim"
vpcSubnetId = "subnet-58839511"
keyPairName = ""
instanceType = "c5d.xlarge"
securityGroups = listOf("sg-eda08696", "sg-7332cf0f")
useSpotInstances = true
instanceTags = mapOf(
"project" to "idea-vim"
)
source = Source("ami-0fa17ce8238eb8868")
}
val feature2 = find<AmazonEC2CloudProfile> {
amazonEC2CloudProfile {
id = "amazon-48"
name = "Cloud Agents - Single Build"
terminateAfterBuild = true
terminateIdleMinutes = 15
region = AmazonEC2CloudProfile.Regions.EU_WEST_DUBLIN
maxInstancesCount = 10
authType = accessKey {
keyId = "credentialsJSON:dbcdb2a2-de5f-4bc9-9421-292b19e83947"
secretKey = "credentialsJSON:65a87fe7-0977-4af9-96f1-344f2b82d269"
}
param("agentPushPreset", "")
}
}
feature2.apply {
name = "Cloud Agents - Single Build"
terminateAfterBuild = true
terminateIdleMinutes = 15
region = AmazonEC2CloudProfile.Regions.EU_WEST_DUBLIN
maxInstancesCount = 10
}
}
}

View File

@@ -0,0 +1,25 @@
package patches.vcsRoots
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.ui.*
import jetbrains.buildServer.configs.kotlin.v2019_2.vcs.GitVcsRoot
/*
This patch script was generated by TeamCity on settings change in UI.
To apply the patch, create a vcsRoot with id = 'HttpsGithubComAlexPl292IdeaVimCompatibilityRefsHeadsMaster'
in the root project, and delete the patch script.
*/
create(DslContext.projectId, GitVcsRoot({
id("HttpsGithubComAlexPl292IdeaVimCompatibilityRefsHeadsMaster")
name = "https://github.com/AlexPl292/IdeaVimCompatibility#refs/heads/master"
url = "https://github.com/AlexPl292/IdeaVimCompatibility"
branch = "refs/heads/master"
branchSpec = "refs/heads/*"
authMethod = password {
userName = "AlexPl292"
password = "credentialsJSON:43afd6e5-6ad5-4d12-a218-cf1547717a7f"
}
param("oauthProviderId", "PROJECT_EXT_1")
param("useAlternates", "true")
}))

View File

@@ -0,0 +1,23 @@
package patches.vcsRoots
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.ui.*
import jetbrains.buildServer.configs.kotlin.v2019_2.vcs.GitVcsRoot
/*
This patch script was generated by TeamCity on settings change in UI.
To apply the patch, create a vcsRoot with id = 'IdeaVimCompatibility'
in the root project, and delete the patch script.
*/
create(DslContext.projectId, GitVcsRoot({
id("IdeaVimCompatibility")
name = "IdeaVimCompatibility"
url = "git@github.com:AlexPl292/IdeaVimCompatibility.git"
branch = "refs/heads/master"
authMethod = uploadedKey {
userName = "git"
uploadedKey = "Alex Plate TeamCity key"
}
param("useAlternates", "true")
}))

View File

@@ -56,6 +56,7 @@ usual beta standards.
* [VIM-744](https://youtrack.jetbrains.com/issue/VIM-744/Use-undoredo-with-count-modifier) Add count to undo/redo
* [VIM-1862](https://youtrack.jetbrains.com/issue/VIM-1862/Ex-commands-executed-in-keymaps-and-macros-are-added-to-the-command-history) Fix command history
* [VIM-2227](https://youtrack.jetbrains.com/issue/VIM-2227) Wrong behavior when deleting / changing surround with invalid character
* [VIM-2691](https://youtrack.jetbrains.com/issue/VIM-2691) Save file on :w
### Merged PRs:
* [468](https://github.com/JetBrains/ideavim/pull/468) by [Thomas Schouten](https://github.com/PHPirates): Implement UserDataHolder for EditorDataContext

View File

@@ -24,7 +24,7 @@ plugins {
java
kotlin("jvm") version "1.6.21"
id("org.jetbrains.intellij") version "1.6.0"
id("org.jetbrains.intellij") version "1.7.0-SNAPSHOT"
id("org.jetbrains.changelog") version "1.3.1"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
@@ -70,7 +70,7 @@ dependencies {
runtimeOnly("org.antlr:antlr4-runtime:$antlrVersion")
antlr("org.antlr:antlr4:$antlrVersion")
implementation(project(":vim-engine"))
api(project(":vim-engine"))
}
configurations {
@@ -145,6 +145,7 @@ tasks {
kotlinOptions {
jvmTarget = javaVersion
apiVersion = "1.5"
freeCompilerArgs = listOf("-Xjvm-default=all-compatibility")
// allWarningsAsErrors = true
}
}
@@ -211,6 +212,25 @@ tasks {
named("compileKotlin") {
dependsOn("generateGrammarSource")
}
// Add plugin open API sources to the plugin ZIP
val createOpenApiSourceJar by registering(Jar::class) {
// Java sources
from(sourceSets.main.get().java) {
include("**/com/maddyhome/idea/vim/**/*.java")
}
// Kotlin sources
from(kotlin.sourceSets.main.get().kotlin) {
include("**/com/maddyhome/idea/vim/**/*.kt")
}
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("src")
}
buildPlugin {
dependsOn(createOpenApiSourceJar)
from(createOpenApiSourceJar) { into("lib/src") }
}
}
// --- Linting

View File

@@ -1,9 +1,9 @@
# suppress inspection "UnusedProperty" for whole file
ideaVersion=LATEST-EAP-SNAPSHOT
ideaVersion=2022.1.2
downloadIdeaSources=true
instrumentPluginCode=true
version=SNAPSHOT
version=chylex-12
javaVersion=11
remoteRobotVersion=0.11.10
antlrVersion=4.10.1

View File

@@ -1,3 +1,13 @@
// Set repository for snapshot versions of gradle plugin
pluginManagement {
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
gradlePluginPortal()
}
}
rootProject.name = 'IdeaVIM'
include 'vim-engine'

View File

@@ -148,6 +148,10 @@ class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
if (keyCode == KeyEvent.VK_TAB && editor.isTemplateActive()) return false
if ((keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_ENTER) && editor.appCodeTemplateCaptured()) return false
if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT) return false
if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) return false
if (keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_END) return false
if (editor.inInsertMode) {
if (keyCode == KeyEvent.VK_TAB) {

View File

@@ -34,7 +34,7 @@ import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VimActionHandler
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.MessageHelper
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.helper.enumSetOf
import com.maddyhome.idea.vim.newapi.ij
import java.util.*
@@ -61,7 +61,7 @@ class OperatorAction : VimActionHandler.SingleExecution() {
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
val argument = cmd.argument ?: return false
if (!editor.commandState.isDotRepeatInProgress) {
if (!editor.vimStateMachine.isDotRepeatInProgress) {
argumentCaptured = argument
}
val range = getMotionRange(editor, context, argument, operatorArguments)

View File

@@ -25,14 +25,14 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.VimActionHandler
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.ij
class RepeatChangeAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_WRITABLE
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
val state = editor.commandState
val state = editor.vimStateMachine
val lastCommand = VimRepeater.lastChangeCommand
if (lastCommand == null && Extension.lastExtensionHandler == null) return false

View File

@@ -0,0 +1,89 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2022 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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
/**
* COMPATIBILITY-LAYER: Additional class
*/
class CommandState(private val machine: VimStateMachine) {
val isOperatorPending: Boolean
get() = machine.isOperatorPending
enum class Mode {
// Basic modes
COMMAND, VISUAL, SELECT, INSERT, CMD_LINE, /*EX*/
// Additional modes
OP_PENDING, REPLACE /*, VISUAL_REPLACE*/, INSERT_NORMAL, INSERT_VISUAL, INSERT_SELECT
}
enum class SubMode {
NONE, VISUAL_CHARACTER, VISUAL_LINE, VISUAL_BLOCK
}
companion object {
@JvmStatic
fun getInstance(editor: Editor): CommandState {
return CommandState(editor.vim.vimStateMachine)
}
}
}
val CommandState.SubMode.engine: VimStateMachine.SubMode
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
}
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
}
val VimStateMachine.Mode.ij: CommandState.Mode
get() = when (this) {
VimStateMachine.Mode.COMMAND -> CommandState.Mode.COMMAND
VimStateMachine.Mode.VISUAL -> CommandState.Mode.VISUAL
VimStateMachine.Mode.SELECT -> CommandState.Mode.SELECT
VimStateMachine.Mode.INSERT -> CommandState.Mode.INSERT
VimStateMachine.Mode.CMD_LINE -> CommandState.Mode.CMD_LINE
VimStateMachine.Mode.OP_PENDING -> CommandState.Mode.OP_PENDING
VimStateMachine.Mode.REPLACE -> CommandState.Mode.REPLACE
VimStateMachine.Mode.INSERT_NORMAL -> CommandState.Mode.INSERT_NORMAL
VimStateMachine.Mode.INSERT_VISUAL -> CommandState.Mode.INSERT_VISUAL
VimStateMachine.Mode.INSERT_SELECT -> CommandState.Mode.INSERT_SELECT
}

View File

@@ -23,14 +23,14 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.change.Extension
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.common.CommandAlias
import com.maddyhome.idea.vim.common.CommandAliasHandler
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.helper.CommandLineHelper
import com.maddyhome.idea.vim.helper.EditorDataContext
import com.maddyhome.idea.vim.helper.TestInputModel
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.key.MappingOwner
import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.newapi.vim
@@ -46,6 +46,21 @@ import javax.swing.KeyStroke
* @author vlan
*/
object VimExtensionFacade {
/** The 'map' command for mapping keys to handlers defined in extensions. */
@JvmStatic
fun putExtensionHandlerMapping(
modes: Set<MappingMode>,
fromKeys: List<KeyStroke>,
pluginOwner: MappingOwner,
extensionHandler: ExtensionHandler,
recursive: Boolean,
) {
VimPlugin.getKey().putKeyMapping(modes, fromKeys, pluginOwner, extensionHandler, recursive)
}
/**
* COMPATIBILITY-LAYER: Additional method
*/
/** The 'map' command for mapping keys to handlers defined in extensions. */
@JvmStatic
fun putExtensionHandlerMapping(
@@ -129,7 +144,7 @@ object VimExtensionFacade {
/** Returns a single key stroke from the user input similar to 'getchar()'. */
@JvmStatic
fun inputKeyStroke(editor: Editor): KeyStroke {
if (editor.vim.commandState.isDotRepeatInProgress) {
if (editor.vim.vimStateMachine.isDotRepeatInProgress) {
val input = Extension.consumeKeystroke()
return input ?: error("Not enough keystrokes saved: ${Extension.lastExtensionHandler}")
}
@@ -137,7 +152,7 @@ object VimExtensionFacade {
val key: KeyStroke? = if (ApplicationManager.getApplication().isUnitTestMode) {
val mappingStack = KeyHandler.getInstance().keyStack
mappingStack.feedSomeStroke() ?: TestInputModel.getInstance(editor).nextKeyStroke()?.also {
if (editor.vim.commandState.isRecording) {
if (editor.vim.vimStateMachine.isRecording) {
KeyHandler.getInstance().modalEntryKeys += it
}
}

View File

@@ -0,0 +1,38 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2022 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.extension
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.newapi.ij
/**
* COMPATIBILITY-LAYER: Created a class, renamed original class
*/
interface VimExtensionHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
execute(editor.ij, context.ij)
}
fun execute(editor: Editor, context: DataContext)
abstract class WithCallback : ExtensionHandler.WithCallback(), VimExtensionHandler
}

View File

@@ -27,7 +27,7 @@ import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.key.MappingOwner.Plugin.Companion.remove
import com.maddyhome.idea.vim.options.OptionChangeListener
import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.options.ToggleOption
import com.maddyhome.idea.vim.option.ToggleOption
import com.maddyhome.idea.vim.statistic.PluginState
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType

View File

@@ -18,24 +18,21 @@
package com.maddyhome.idea.vim.extension.argtextobj;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.api.*;
import com.maddyhome.idea.vim.command.*;
import com.maddyhome.idea.vim.common.MappingMode;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.extension.VimExtension;
import com.maddyhome.idea.vim.extension.VimExtensionHandler;
import com.maddyhome.idea.vim.extension.ExtensionHandler;
import com.maddyhome.idea.vim.handler.TextObjectActionHandler;
import com.maddyhome.idea.vim.helper.InlayHelperKt;
import com.maddyhome.idea.vim.helper.MessageHelper;
import com.maddyhome.idea.vim.helper.VimNlsSafe;
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor;
import com.maddyhome.idea.vim.listener.VimListenerSuppressor;
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
import com.maddyhome.idea.vim.newapi.IjVimCaret;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
@@ -186,7 +183,7 @@ public class VimArgTextObjExtension implements VimExtension {
/**
* A text object for an argument to a function definition or a call.
*/
static class ArgumentHandler implements VimExtensionHandler {
static class ArgumentHandler implements ExtensionHandler {
final boolean isInner;
ArgumentHandler(boolean isInner) {
@@ -262,17 +259,17 @@ public class VimArgTextObjExtension implements VimExtension {
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
IjVimEditor vimEditor = (IjVimEditor) editor;
@NotNull CommandState commandState = CommandState.getInstance(vimEditor);
int count = Math.max(1, commandState.getCommandBuilder().getCount());
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(vimEditor);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final ArgumentTextObjectHandler textObjectHandler = new ArgumentTextObjectHandler(isInner);
//noinspection DuplicatedCode
if (!commandState.isOperatorPending()) {
if (!vimStateMachine.isOperatorPending()) {
vimEditor.getEditor().getCaretModel().runForEachCaret((Caret caret) -> {
final TextRange range = textObjectHandler.getRange(vimEditor, new IjVimCaret(caret), context, count, 0, null);
if (range != null) {
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
if (commandState.getMode() == CommandState.Mode.VISUAL) {
if (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
} else {
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
@@ -282,8 +279,8 @@ public class VimArgTextObjExtension implements VimExtension {
});
} else {
commandState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags.class))));
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags.class))));
}
}
}

View File

@@ -34,11 +34,11 @@ import com.maddyhome.idea.vim.api.injector
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.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.CommandAliasHandler
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.extension.VimExtension
@@ -48,11 +48,11 @@ import com.maddyhome.idea.vim.extension.VimExtensionFacade.putExtensionHandlerMa
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMapping
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction
import com.maddyhome.idea.vim.extension.VimExtensionHandler
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.PsiHelper
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.newapi.IjVimEditor
import com.maddyhome.idea.vim.newapi.ij
@@ -63,8 +63,8 @@ class CommentaryExtension : VimExtension {
companion object {
fun doCommentary(editor: VimEditor, context: ExecutionContext, range: TextRange, selectionType: SelectionType, resetCaret: Boolean): Boolean {
val mode = editor.commandState.mode
if (mode !== CommandState.Mode.VISUAL) {
val mode = editor.vimStateMachine.mode
if (mode !== VimStateMachine.Mode.VISUAL) {
editor.ij.selectionModel.setSelection(range.startOffset, range.endOffset)
}
@@ -82,7 +82,7 @@ class CommentaryExtension : VimExtension {
injector.actionExecutor.executeAction(actions[1], context)
} finally {
// Remove the selection, if we added it
if (mode !== CommandState.Mode.VISUAL) {
if (mode !== VimStateMachine.Mode.VISUAL) {
editor.removeSelection()
}
@@ -129,7 +129,7 @@ class CommentaryExtension : VimExtension {
* E.g. handles the `gc` in `gc_`, by setting the operator function, then invoking `g@` to receive the `_` motion to
* invoke the operator. This object is both the mapping handler and the operator function.
*/
private class CommentaryOperatorHandler : OperatorFunction, VimExtensionHandler {
private class CommentaryOperatorHandler : OperatorFunction, ExtensionHandler {
override val isRepeatable = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
@@ -148,11 +148,11 @@ class CommentaryExtension : VimExtension {
*
* This object is both the `<Plug>Commentary` mapping handler and the text object handler
*/
private class CommentaryTextObjectMotionHandler : TextObjectActionHandler(), VimExtensionHandler {
private class CommentaryTextObjectMotionHandler : TextObjectActionHandler(), ExtensionHandler {
override val isRepeatable = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
val commandState = editor.commandState
val commandState = editor.vimStateMachine
val count = maxOf(1, commandState.commandBuilder.count)
val textObjectHandler = this

View File

@@ -31,9 +31,9 @@ import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
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.SelectionType
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.VimExtension
import com.maddyhome.idea.vim.extension.VimExtensionFacade.executeNormalWithoutMapping
@@ -42,7 +42,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.setRegister
import com.maddyhome.idea.vim.extension.VimExtensionHandler
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.fileSize
import com.maddyhome.idea.vim.helper.moveToInlayAwareLogicalPosition
@@ -95,7 +95,7 @@ class VimExchangeExtension : VimExtension {
val EXCHANGE_KEY = Key<Exchange>("exchange")
// End mark has always greater of eq offset than start mark
class Exchange(val type: CommandState.SubMode, val start: Mark, val end: Mark, val text: String) {
class Exchange(val type: VimStateMachine.SubMode, val start: Mark, val end: Mark, val text: String) {
private var myHighlighter: RangeHighlighter? = null
fun setHighlighter(highlighter: RangeHighlighter) {
myHighlighter = highlighter
@@ -112,7 +112,7 @@ class VimExchangeExtension : VimExtension {
}
}
private class ExchangeHandler(private val isLine: Boolean) : VimExtensionHandler {
private class ExchangeHandler(private val isLine: Boolean) : ExtensionHandler {
override val isRepeatable = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
@@ -121,13 +121,13 @@ class VimExchangeExtension : VimExtension {
}
}
private class ExchangeClearHandler : VimExtensionHandler {
private class ExchangeClearHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
clearExchange(editor.ij)
}
}
private class VExchangeHandler : VimExtensionHandler {
private class VExchangeHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
runWriteAction {
val subMode = editor.subMode
@@ -140,10 +140,10 @@ class VimExchangeExtension : VimExtension {
private class Operator(private val isVisual: Boolean) : OperatorFunction {
fun Editor.getMarkOffset(mark: Mark) = EditorHelper.getOffset(this, mark.logicalLine, mark.col)
fun CommandState.SubMode.getString() = when (this) {
CommandState.SubMode.VISUAL_CHARACTER -> "v"
CommandState.SubMode.VISUAL_LINE -> "V"
CommandState.SubMode.VISUAL_BLOCK -> "\\<C-V>"
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")
}
@@ -151,7 +151,7 @@ class VimExchangeExtension : VimExtension {
fun highlightExchange(ex: Exchange): RangeHighlighter {
val attributes = editor.colorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES)
val hlArea = when (ex.type) {
CommandState.SubMode.VISUAL_LINE -> HighlighterTargetArea.LINES_IN_RANGE
VimStateMachine.SubMode.VISUAL_LINE -> HighlighterTargetArea.LINES_IN_RANGE
// TODO: handle other modes
else -> HighlighterTargetArea.EXACT_RANGE
}
@@ -274,7 +274,7 @@ class VimExchangeExtension : VimExtension {
x.logicalLine - y.logicalLine
}
return if (x.type == CommandState.SubMode.VISUAL_BLOCK && y.type == CommandState.SubMode.VISUAL_BLOCK) {
return if (x.type == VimStateMachine.SubMode.VISUAL_BLOCK && y.type == VimStateMachine.SubMode.VISUAL_BLOCK) {
when {
intersects(x, y) -> {
ExchangeCompareResult.OVERLAP

View File

@@ -36,17 +36,17 @@ import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.MotionType
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.common.Direction
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.extension.VimExtension
import com.maddyhome.idea.vim.extension.VimExtensionFacade
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing
import com.maddyhome.idea.vim.extension.VimExtensionHandler
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.handler.Motion
import com.maddyhome.idea.vim.handler.MotionActionHandler
import com.maddyhome.idea.vim.handler.toMotionOrError
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.PsiHelper
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.helper.enumSetOf
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim
@@ -94,14 +94,14 @@ class Matchit : VimExtension {
override var motionType: MotionType = MotionType.INCLUSIVE
}
private class MatchitHandler(private val reverse: Boolean) : VimExtensionHandler {
private class MatchitHandler(private val reverse: Boolean) : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
val commandState = editor.commandState
val commandState = editor.vimStateMachine
val count = commandState.commandBuilder.count
// Reset the command count so it doesn't transfer onto subsequent commands.
editor.commandState.commandBuilder.resetCount()
editor.vimStateMachine.commandBuilder.resetCount()
// Normally we want to jump to the start of the matching pair. But when moving forward in operator
// pending mode, we want to include the entire match. isInOpPending makes that distinction.
@@ -233,7 +233,7 @@ private object FileTypePatterns {
} else if (fileTypeName == "CMakeLists.txt" || fileName == "CMakeLists") {
this.cMakePatterns
} else {
return null
this.htmlPatterns
}
}

View File

@@ -29,13 +29,13 @@ import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.extension.VimExtension
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putExtensionHandlerMapping
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing
import com.maddyhome.idea.vim.extension.VimExtensionHandler
import com.maddyhome.idea.vim.group.MotionGroup
import com.maddyhome.idea.vim.group.visual.vimSetSelection
import com.maddyhome.idea.vim.helper.EditorHelper
@@ -111,7 +111,7 @@ class VimMultipleCursorsExtension : VimExtension {
putKeyMappingIfMissing(MappingMode.X, injector.parser.parseKeys("<A-p>"), owner, injector.parser.parseKeys(REMOVE_OCCURRENCE), true)
}
abstract class WriteActionHandler : VimExtensionHandler {
abstract class WriteActionHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
ApplicationManager.getApplication().runWriteAction {
executeInWriteAction(editor.ij, context.ij)
@@ -313,7 +313,7 @@ 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, CommandState.SubMode.VISUAL_CHARACTER)
VimPlugin.getVisualMotion().enterVisualMode(editor, VimStateMachine.SubMode.VISUAL_CHARACTER)
KeyHandler.getInstance().reset(editor)
}

View File

@@ -23,11 +23,11 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.extension.VimExtension
import com.maddyhome.idea.vim.extension.VimExtensionFacade
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing
import com.maddyhome.idea.vim.extension.VimExtensionHandler
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.group.MotionGroup
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.SearchHelper
@@ -45,7 +45,7 @@ class ParagraphMotion : VimExtension {
putKeyMappingIfMissing(MappingMode.NXO, injector.parser.parseKeys("{"), owner, injector.parser.parseKeys("<Plug>(ParagraphPrevMotion)"), true)
}
private class ParagraphMotionHandler(private val count: Int) : VimExtensionHandler {
private class ParagraphMotionHandler(private val count: Int) : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
editor.ij.vimForEachCaret { caret ->
val motion = moveCaretToNextParagraph(editor.ij, caret, count)

View File

@@ -25,17 +25,17 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimCaret
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.MappingMode
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.common.MappingMode
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.extension.VimExtension
import com.maddyhome.idea.vim.extension.VimExtensionFacade
import com.maddyhome.idea.vim.extension.VimExtensionFacade.executeNormalWithoutMapping
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction
import com.maddyhome.idea.vim.extension.VimExtensionHandler
import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.helper.EditorDataContext
import com.maddyhome.idea.vim.helper.mode
@@ -63,7 +63,7 @@ class ReplaceWithRegister : VimExtension {
putKeyMappingIfMissing(MappingMode.X, injector.parser.parseKeys("gr"), owner, injector.parser.parseKeys(RWR_VISUAL), true)
}
private class RwrVisual : VimExtensionHandler {
private class RwrVisual : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
val caretsAndSelections = mutableMapOf<VimCaret, VimSelection>()
val typeInEditor = SelectionType.fromSubMode(editor.subMode)
@@ -78,7 +78,7 @@ class ReplaceWithRegister : VimExtension {
}
}
private class RwrMotion : VimExtensionHandler {
private class RwrMotion : ExtensionHandler {
override val isRepeatable: Boolean = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
@@ -87,7 +87,7 @@ class ReplaceWithRegister : VimExtension {
}
}
private class RwrLine : VimExtensionHandler {
private class RwrLine : ExtensionHandler {
override val isRepeatable: Boolean = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
@@ -131,8 +131,8 @@ class ReplaceWithRegister : VimExtension {
}
private fun getRange(editor: Editor): TextRange? = when (editor.vim.mode) {
CommandState.Mode.COMMAND -> VimPlugin.getMark().getChangeMarks(editor.vim)
CommandState.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
VimStateMachine.Mode.COMMAND -> VimPlugin.getMark().getChangeMarks(editor.vim)
VimStateMachine.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
else -> null
}
}

View File

@@ -25,10 +25,11 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimChangeGroup
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.common.MappingMode
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
import com.maddyhome.idea.vim.extension.VimExtensionFacade.executeNormalWithoutMapping
import com.maddyhome.idea.vim.extension.VimExtensionFacade.getRegister
@@ -38,9 +39,8 @@ 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.setRegister
import com.maddyhome.idea.vim.extension.VimExtensionHandler
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.editorMode
import com.maddyhome.idea.vim.helper.runWithEveryCaretAndRestore
import com.maddyhome.idea.vim.key.OperatorFunction
import com.maddyhome.idea.vim.newapi.IjVimCaret
@@ -82,7 +82,7 @@ class VimSurroundExtension : VimExtension {
}
}
private class YSurroundHandler : VimExtensionHandler {
private class YSurroundHandler : ExtensionHandler {
override val isRepeatable = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
@@ -91,7 +91,7 @@ class VimSurroundExtension : VimExtension {
}
}
private class VSurroundHandler : VimExtensionHandler {
private class VSurroundHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext) {
// NB: Operator ignores SelectionType anyway
if (!Operator(supportsMultipleCursors = true).apply(editor.ij, context.ij, SelectionType.CHARACTER_WISE)) {
@@ -104,7 +104,7 @@ class VimSurroundExtension : VimExtension {
}
}
private class CSurroundHandler : VimExtensionHandler {
private class CSurroundHandler : ExtensionHandler {
override val isRepeatable = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
@@ -176,7 +176,7 @@ class VimSurroundExtension : VimExtension {
}
}
private class DSurroundHandler : VimExtensionHandler {
private class DSurroundHandler : ExtensionHandler {
override val isRepeatable = true
override fun execute(editor: VimEditor, context: ExecutionContext) {
@@ -226,9 +226,9 @@ class VimSurroundExtension : VimExtension {
}
}
private fun getSurroundRange(editor: Editor): TextRange? = when (editor.mode) {
CommandState.Mode.COMMAND -> VimPlugin.getMark().getChangeMarks(editor.vim)
CommandState.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
private fun getSurroundRange(editor: Editor): TextRange? = when (editor.editorMode) {
VimStateMachine.Mode.COMMAND -> VimPlugin.getMark().getChangeMarks(editor.vim)
VimStateMachine.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
else -> null
}
}

View File

@@ -18,26 +18,22 @@
package com.maddyhome.idea.vim.extension.textobjentire;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.maddyhome.idea.vim.api.ExecutionContext;
import com.maddyhome.idea.vim.api.VimCaret;
import com.maddyhome.idea.vim.api.VimEditor;
import com.maddyhome.idea.vim.api.VimInjectorKt;
import com.maddyhome.idea.vim.command.*;
import com.maddyhome.idea.vim.common.MappingMode;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.extension.VimExtension;
import com.maddyhome.idea.vim.extension.VimExtensionHandler;
import com.maddyhome.idea.vim.extension.ExtensionHandler;
import com.maddyhome.idea.vim.handler.TextObjectActionHandler;
import com.maddyhome.idea.vim.helper.InlayHelperKt;
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor;
import com.maddyhome.idea.vim.listener.VimListenerSuppressor;
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
import com.maddyhome.idea.vim.newapi.IjVimCaret;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
import org.apache.tools.ant.taskdefs.Exec;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -88,7 +84,7 @@ public class VimTextObjEntireExtension implements VimExtension {
putKeyMappingIfMissing(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("ie"), getOwner(), VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-entire-i"), true);
}
static class EntireHandler implements VimExtensionHandler {
static class EntireHandler implements ExtensionHandler {
final boolean ignoreLeadingAndTrailing;
EntireHandler(boolean ignoreLeadingAndTrailing) {
@@ -148,17 +144,17 @@ public class VimTextObjEntireExtension implements VimExtension {
@Override
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
@NotNull CommandState commandState = CommandState.getInstance(editor);
int count = Math.max(1, commandState.getCommandBuilder().getCount());
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(editor);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final EntireTextObjectHandler textObjectHandler = new EntireTextObjectHandler(ignoreLeadingAndTrailing);
//noinspection DuplicatedCode
if (!commandState.isOperatorPending()) {
if (!vimStateMachine.isOperatorPending()) {
((IjVimEditor) editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> {
final TextRange range = textObjectHandler.getRange(editor, new IjVimCaret(caret), context, count, 0, null);
if (range != null) {
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
if (commandState.getMode() == CommandState.Mode.VISUAL) {
if (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
} else {
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
@@ -168,9 +164,9 @@ public class VimTextObjEntireExtension implements VimExtension {
});
} else {
commandState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
}
}
}

View File

@@ -18,23 +18,20 @@
package com.maddyhome.idea.vim.extension.textobjindent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.maddyhome.idea.vim.api.ExecutionContext;
import com.maddyhome.idea.vim.api.VimCaret;
import com.maddyhome.idea.vim.api.VimEditor;
import com.maddyhome.idea.vim.api.VimInjectorKt;
import com.maddyhome.idea.vim.command.*;
import com.maddyhome.idea.vim.common.MappingMode;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.extension.VimExtension;
import com.maddyhome.idea.vim.extension.VimExtensionHandler;
import com.maddyhome.idea.vim.extension.ExtensionHandler;
import com.maddyhome.idea.vim.handler.TextObjectActionHandler;
import com.maddyhome.idea.vim.helper.InlayHelperKt;
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor;
import com.maddyhome.idea.vim.listener.VimListenerSuppressor;
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
import com.maddyhome.idea.vim.newapi.IjVimCaret;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
import org.jetbrains.annotations.NotNull;
@@ -86,7 +83,7 @@ public class VimIndentObject implements VimExtension {
putKeyMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("ii"), getOwner(), VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-ii"), true);
}
static class IndentObject implements VimExtensionHandler {
static class IndentObject implements ExtensionHandler {
final boolean includeAbove;
final boolean includeBelow;
@@ -275,17 +272,17 @@ public class VimIndentObject implements VimExtension {
@Override
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
IjVimEditor vimEditor = (IjVimEditor)editor;
@NotNull CommandState commandState = CommandState.getInstance(vimEditor);
int count = Math.max(1, commandState.getCommandBuilder().getCount());
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(vimEditor);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow);
if (!commandState.isOperatorPending()) {
if (!vimStateMachine.isOperatorPending()) {
((IjVimEditor)editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> {
final TextRange range = textObjectHandler.getRange(vimEditor, new IjVimCaret(caret), context, count, 0, null);
if (range != null) {
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
if (commandState.getMode() == CommandState.Mode.VISUAL) {
if (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
} else {
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
@@ -295,9 +292,9 @@ public class VimIndentObject implements VimExtension {
});
} else {
commandState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
}
}
}

View File

@@ -50,7 +50,10 @@ import com.maddyhome.idea.vim.group.visual.VisualModeHelperKt;
import com.maddyhome.idea.vim.helper.*;
import com.maddyhome.idea.vim.key.KeyHandlerKeeper;
import com.maddyhome.idea.vim.listener.VimInsertListener;
import com.maddyhome.idea.vim.newapi.*;
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
import com.maddyhome.idea.vim.newapi.IjExecutionContextKt;
import com.maddyhome.idea.vim.newapi.IjVimCaret;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
import com.maddyhome.idea.vim.options.OptionConstants;
import com.maddyhome.idea.vim.options.OptionScope;
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
@@ -106,7 +109,7 @@ public class ChangeGroup extends VimChangeGroupBase {
injector.getMotion().moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret));
}
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), VimStateMachine.Mode.INSERT);
insertText(editor, caret, "\n" + IndentConfig.create(((IjVimEditor) editor).getEditor()).createIndentBySize(col));
if (firstLiner) {
@@ -125,7 +128,7 @@ public class ChangeGroup extends VimChangeGroupBase {
if (editor.isOneLineMode()) return;
caret.moveToOffset(injector.getMotion().moveCaretToLineEnd(editor, caret));
editor.setVimChangeActionSwitchMode(CommandState.Mode.INSERT);
editor.setVimChangeActionSwitchMode(VimStateMachine.Mode.INSERT);
insertText(editor, caret, "\n" + IndentConfig.create(((IjVimEditor) editor).getEditor()).createIndentBySize(col));
}
@@ -200,6 +203,61 @@ public class ChangeGroup extends VimChangeGroupBase {
return new Pair<>(range, type);
}
/**
* Delete the range of text.
*
* @param editor The editor to delete the text from
* @param caret The caret to be moved after deletion
* @param range The range to delete
* @param type The type of deletion
* @param isChange Is from a change action
* @return true if able to delete the text, false if not
*/
@Override
public boolean deleteRange(@NotNull VimEditor editor,
@NotNull VimCaret caret,
@NotNull TextRange range,
@Nullable SelectionType type,
boolean isChange,
boolean noYank) {
// Update the last column before we delete, or we might be retrieving the data for a line that no longer exists
UserDataManager.setVimLastColumn(((IjVimCaret) caret).getCaret(), InlayHelperKt.getInlayAwareVisualColumn(((IjVimCaret) caret).getCaret()));
boolean removeLastNewLine = removeLastNewLine(editor, range, type);
final boolean res = deleteText(editor, range, type, noYank);
if (removeLastNewLine) {
int textLength = ((IjVimEditor) editor).getEditor().getDocument().getTextLength();
((IjVimEditor) editor).getEditor().getDocument().deleteString(textLength - 1, textLength);
}
if (res) {
int pos = EditorHelper.normalizeOffset(((IjVimEditor) editor).getEditor(), range.getStartOffset(), isChange);
if (type == SelectionType.LINE_WISE) {
pos = VimPlugin.getMotion()
.moveCaretToLineWithStartOfLineOption(editor, editor.offsetToLogicalPosition(pos).getLine(),
caret);
}
injector.getMotion().moveCaret(editor, caret, pos);
}
return res;
}
private boolean removeLastNewLine(@NotNull VimEditor editor, @NotNull TextRange range, @Nullable SelectionType type) {
int endOffset = range.getEndOffset();
int fileSize = EditorHelperRt.getFileSize(((IjVimEditor) editor).getEditor());
if (endOffset > fileSize) {
if (injector.getOptionService().isSet(OptionScope.GLOBAL.INSTANCE, OptionConstants.ideastrictmodeName, OptionConstants.ideastrictmodeName)) {
throw new IllegalStateException("Incorrect offset. File size: " + fileSize + ", offset: " + endOffset);
}
endOffset = fileSize;
}
return type == SelectionType.LINE_WISE &&
range.getStartOffset() != 0 &&
((IjVimEditor) editor).getEditor().getDocument().getCharsSequence().charAt(endOffset - 1) != '\n' &&
endOffset == fileSize;
}
@Override
public void insertLineAround(@NotNull VimEditor editor, @NotNull ExecutionContext context, int shift) {
com.maddyhome.idea.vim.newapi.ChangeGroupKt.insertLineAround(editor, context, shift);
@@ -228,7 +286,8 @@ public class ChangeGroup extends VimChangeGroupBase {
@NotNull VimCaret caret,
@NotNull ExecutionContext context,
@NotNull Argument argument,
@NotNull OperatorArguments operatorArguments) {
@NotNull OperatorArguments operatorArguments,
boolean noYank) {
int count0 = operatorArguments.getCount0();
// Vim treats cw as ce and cW as cE if cursor is on a non-blank character
final Command motion = argument.getMotion();
@@ -247,7 +306,7 @@ public class ChangeGroup extends VimChangeGroupBase {
if (wordMotions.contains(id) && lastWordChar && motion.getCount() == 1) {
final boolean res = deleteCharacter(editor, caret, 1, true);
if (res) {
editor.setVimChangeActionSwitchMode(CommandState.Mode.INSERT);
editor.setVimChangeActionSwitchMode(VimStateMachine.Mode.INSERT);
}
return res;
}
@@ -306,7 +365,7 @@ public class ChangeGroup extends VimChangeGroupBase {
Pair<TextRange, SelectionType> deleteRangeAndType =
getDeleteRangeAndType(editor, caret, context, argument, true, operatorArguments.withCount0(count0));
if (deleteRangeAndType == null) return false;
return changeRange(editor, caret, deleteRangeAndType.getFirst(), deleteRangeAndType.getSecond(), context);
return changeRange(editor, caret, deleteRangeAndType.getFirst(), deleteRangeAndType.getSecond(), context, noYank);
}
}
@@ -338,8 +397,8 @@ public class ChangeGroup extends VimChangeGroupBase {
final int lines = VimChangeGroupBase.Companion.getLinesCountInVisualBlock(editor, range);
final VimLogicalPosition startPosition = editor.offsetToLogicalPosition(range.getStartOffset());
boolean visualBlockMode = operatorArguments.getMode() == CommandState.Mode.VISUAL &&
operatorArguments.getSubMode() == CommandState.SubMode.VISUAL_BLOCK;
boolean visualBlockMode = operatorArguments.getMode() == VimStateMachine.Mode.VISUAL &&
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK;
for (Caret caret : ((IjVimEditor) editor).getEditor().getCaretModel().getAllCarets()) {
final int line = startPosition.getLine();
int column = startPosition.getColumn();
@@ -436,7 +495,8 @@ public class ChangeGroup extends VimChangeGroupBase {
@NotNull VimCaret caret,
@NotNull TextRange range,
@NotNull SelectionType type,
ExecutionContext context) {
@Nullable ExecutionContext context,
boolean noYank) {
int col = 0;
int lines = 0;
if (type == SelectionType.BLOCK_WISE) {
@@ -450,7 +510,7 @@ public class ChangeGroup extends VimChangeGroupBase {
final VimLogicalPosition lp = editor.offsetToLogicalPosition(injector.getMotion().moveCaretToLineStartSkipLeading(editor, caret));
boolean res = deleteRange(editor, caret, range, type, true);
boolean res = deleteRange(editor, caret, range, type, true, noYank);
if (res) {
if (type == SelectionType.LINE_WISE) {
// Please don't use `getDocument().getText().isEmpty()` because it converts CharSequence into String
@@ -468,7 +528,7 @@ public class ChangeGroup extends VimChangeGroupBase {
if (type == SelectionType.BLOCK_WISE) {
setInsertRepeat(lines, col, false);
}
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), VimStateMachine.Mode.INSERT);
}
}
else {
@@ -675,7 +735,7 @@ public class ChangeGroup extends VimChangeGroupBase {
}
}
if (pos > wsoff) {
deleteText(editor, new TextRange(wsoff, pos), null);
deleteText(editor, new TextRange(wsoff, pos), null, false);
}
}
}

View File

@@ -38,8 +38,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.api.*;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.common.GoalCommand;
import com.maddyhome.idea.vim.command.VimStateMachine;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.helper.EditorHelper;
import com.maddyhome.idea.vim.helper.EditorHelperRt;
@@ -48,7 +47,6 @@ import com.maddyhome.idea.vim.helper.SearchHelper;
import com.maddyhome.idea.vim.newapi.ExecuteExtensionKt;
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
import com.maddyhome.idea.vim.options.OptionConstants;
import com.maddyhome.idea.vim.options.OptionScope;
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService;
@@ -290,7 +288,7 @@ public class FileGroup extends VimFileBase {
StringBuilder msg = new StringBuilder();
Document doc = editor.getDocument();
if (CommandState.getInstance(new IjVimEditor(editor)).getMode() != CommandState.Mode.VISUAL) {
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() != VimStateMachine.Mode.VISUAL) {
LogicalPosition lp = editor.getCaretModel().getLogicalPosition();
int col = editor.getCaretModel().getOffset() - doc.getLineStartOffset(lp.line);
int endoff = doc.getLineEndOffset(lp.line);

View File

@@ -37,7 +37,7 @@ import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.action.ComplicatedKeysAction;
import com.maddyhome.idea.vim.action.VimShortcutKeyAction;
import com.maddyhome.idea.vim.api.*;
import com.maddyhome.idea.vim.common.MappingMode;
import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.common.Node;
import com.maddyhome.idea.vim.common.NodesKt;
import com.maddyhome.idea.vim.ex.ExOutputModel;

View File

@@ -44,7 +44,6 @@ import com.maddyhome.idea.vim.helper.EditorHelper;
import com.maddyhome.idea.vim.helper.HelperKt;
import com.maddyhome.idea.vim.mark.*;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
import com.maddyhome.idea.vim.options.OptionConstants;
import com.maddyhome.idea.vim.options.OptionScope;
import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService;
import org.jdom.Element;
@@ -60,8 +59,7 @@ import static com.maddyhome.idea.vim.mark.VimMarkConstants.SAVE_FILE_MARKS;
* This class contains all the mark related functionality
*/
@State(name = "VimMarksSettings", storages = {
@Storage(value = "$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)
})
@Storage(value = "$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)})
public class MarkGroup extends VimMarkGroupBase implements PersistentStateComponent<Element> {
public void editorReleased(@NotNull EditorFactoryEvent event) {
// Save off the last caret position of the file before it is closed
@@ -92,7 +90,7 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
*
* @param doc The editor to get the marks for
* @return The map of marks. The keys are <code>Character</code>s of the mark names, the values are
* <code>Mark</code>s.
* <code>Mark</code>s.
*/
private @Nullable FileMarks<Character, Mark> getFileMarks(final @NotNull Document doc) {
VirtualFile vf = FileDocumentManager.getInstance().getFile(doc);
@@ -127,7 +125,8 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
public void saveData(@NotNull Element element) {
Element marksElem = new Element("globalmarks");
if (!VimPlugin.getOptionService().isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) {
if (!VimPlugin.getOptionService()
.isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) {
for (Mark mark : globalMarks.values()) {
if (!mark.isClear()) {
Element markElem = new Element("mark");
@@ -165,8 +164,7 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
fileMarkElem.setAttribute("name", file);
fileMarkElem.setAttribute("timestamp", Long.toString(marks.getMyTimestamp().getTime()));
for (Mark mark : marks.values()) {
if (!mark.isClear() && !Character.isUpperCase(mark.getKey()) &&
SAVE_FILE_MARKS.indexOf(mark.getKey()) >= 0) {
if (!mark.isClear() && !Character.isUpperCase(mark.getKey()) && SAVE_FILE_MARKS.indexOf(mark.getKey()) >= 0) {
Element markElem = new Element("mark");
markElem.setAttribute("key", Character.toString(mark.getKey()));
markElem.setAttribute("line", Integer.toString(mark.getLogicalLine()));
@@ -200,14 +198,15 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
// (see com.intellij.openapi.application.Application.runReadAction())
Element marksElem = element.getChild("globalmarks");
if (marksElem != null && !VimPlugin.getOptionService().isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) {
if (marksElem != null &&
!VimPlugin.getOptionService()
.isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) {
List<Element> markList = marksElem.getChildren("mark");
for (Element aMarkList : markList) {
Mark mark = VimMark.create(aMarkList.getAttributeValue("key").charAt(0),
Integer.parseInt(aMarkList.getAttributeValue("line")),
Integer.parseInt(aMarkList.getAttributeValue("column")),
aMarkList.getAttributeValue("filename"),
aMarkList.getAttributeValue("protocol"));
aMarkList.getAttributeValue("filename"), aMarkList.getAttributeValue("protocol"));
if (mark != null) {
globalMarks.put(mark.getKey(), mark);
@@ -239,8 +238,7 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
for (Element aMarkList : markList) {
Mark mark = VimMark.create(aMarkList.getAttributeValue("key").charAt(0),
Integer.parseInt(aMarkList.getAttributeValue("line")),
Integer.parseInt(aMarkList.getAttributeValue("column")),
filename,
Integer.parseInt(aMarkList.getAttributeValue("column")), filename,
aMarkList.getAttributeValue("protocol"));
if (mark != null) fmarks.put(mark.getKey(), mark);
@@ -290,6 +288,7 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
public static class MarkUpdater implements DocumentListener {
public static MarkUpdater INSTANCE = new MarkUpdater();
/**
* Creates the listener for the supplied editor
*/
@@ -313,8 +312,7 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
Editor anEditor = getAnEditor(doc);
VimInjectorKt.getInjector().getMarkGroup()
.updateMarkFromDelete(anEditor == null ? null : new IjVimEditor(anEditor),
VimPlugin.getMark().getAllFileMarks(doc),
event.getOffset(), event.getOldLength());
VimPlugin.getMark().getAllFileMarks(doc), event.getOffset(), event.getOldLength());
// TODO - update jumps
}
@@ -361,7 +359,10 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
@Override
public void bookmarkAdded(@NotNull BookmarkGroup group, com.intellij.ide.bookmark.@NotNull Bookmark bookmark) {
if (!VimPlugin.isEnabled()) return;
if (!VimPlugin.getOptionService().isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) return;
if (!VimPlugin.getOptionService()
.isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) {
return;
}
if (!(bookmark instanceof LineBookmark)) return;
BookmarksManager bookmarksManager = BookmarksManager.getInstance(myProject);
@@ -378,7 +379,10 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
@Override
public void bookmarkRemoved(@NotNull BookmarkGroup group, com.intellij.ide.bookmark.@NotNull Bookmark bookmark) {
if (!VimPlugin.isEnabled()) return;
if (!VimPlugin.getOptionService().isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) return;
if (!VimPlugin.getOptionService()
.isSet(OptionScope.GLOBAL.INSTANCE, IjVimOptionService.ideamarksName, IjVimOptionService.ideamarksName)) {
return;
}
if (!(bookmark instanceof LineBookmark)) return;
BookmarksManager bookmarksManager = BookmarksManager.getInstance(myProject);
@@ -387,7 +391,8 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
if (type == null) return;
char ch = type.getMnemonic();
if (GLOBAL_MARKS.indexOf(ch) != -1) {
FileMarks<Character, Mark> fmarks = VimPlugin.getMark().getFileMarks(((LineBookmark)bookmark).getFile().getPath());
FileMarks<Character, Mark> fmarks =
VimPlugin.getMark().getFileMarks(((LineBookmark)bookmark).getFile().getPath());
fmarks.remove(ch);
VimPlugin.getMark().globalMarks.remove(ch);
}
@@ -404,6 +409,16 @@ public class MarkGroup extends VimMarkGroupBase implements PersistentStateCompon
}
}
/**
* COMPATIBILITY-LAYER: Method added
*
* @deprecated Please use method with VimEditor
*/
@Deprecated
public void saveJumpLocation(Editor editor) {
this.saveJumpLocation(new IjVimEditor(editor));
}
private static final int SAVE_MARK_COUNT = 20;
private static final Logger logger = Logger.getInstance(MarkGroup.class.getName());

View File

@@ -711,7 +711,7 @@ public class MotionGroup extends VimMotionGroupBase {
}
private static int getScrollJump(@NotNull Editor editor, int height) {
final EnumSet<CommandFlags> flags = CommandState.getInstance(new IjVimEditor(editor)).getExecutingCommandFlags();
final EnumSet<CommandFlags> flags = VimStateMachine.getInstance(new IjVimEditor(editor)).getExecutingCommandFlags();
final boolean scrollJump = !flags.contains(CommandFlags.FLAG_IGNORE_SCROLL_JUMP);
// Default value is 1. Zero is a valid value, but we normalise to 1 - we always want to scroll at least one line
@@ -736,7 +736,7 @@ public class MotionGroup extends VimMotionGroupBase {
final int halfWidth = getApproximateScreenWidth(editor) / 2;
final int scrollOffset = getNormalizedSideScrollOffset(editor);
final EnumSet<CommandFlags> flags = CommandState.getInstance(new IjVimEditor(editor)).getExecutingCommandFlags();
final EnumSet<CommandFlags> flags = VimStateMachine.getInstance(new IjVimEditor(editor)).getExecutingCommandFlags();
final boolean allowSidescroll = !flags.contains(CommandFlags.FLAG_IGNORE_SIDE_SCROLL_JUMP);
int sidescroll = ((VimInt) VimPlugin.getOptionService().getOptionValue(new OptionScope.LOCAL(new IjVimEditor(editor)), OptionConstants.sidescrollName, OptionConstants.sidescrollName)).getValue();
@@ -1200,7 +1200,7 @@ public class MotionGroup extends VimMotionGroupBase {
if (fileEditor instanceof TextEditor) {
final Editor editor = ((TextEditor)fileEditor).getEditor();
ExOutputModel.getInstance(editor).clear();
if (CommandState.getInstance(new IjVimEditor(editor)).getMode() == CommandState.Mode.VISUAL) {
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
ModeHelper.exitVisualMode(editor);
KeyHandler.getInstance().reset(new IjVimEditor(editor));
}

View File

@@ -37,7 +37,7 @@ import com.maddyhome.idea.vim.KeyHandler;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.api.*;
import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.VimStateMachine;
import com.maddyhome.idea.vim.ex.ExException;
import com.maddyhome.idea.vim.ex.InvalidCommandException;
import com.maddyhome.idea.vim.helper.UiHelper;
@@ -90,9 +90,9 @@ public class ProcessGroup extends VimProcessGroupBase {
if (editor.isOneLineMode()) return;
String initText = getRange(((IjVimEditor) editor).getEditor(), cmd);
CommandState.getInstance(editor).pushModes(CommandState.Mode.CMD_LINE, CommandState.SubMode.NONE);
VimStateMachine.getInstance(editor).pushModes(VimStateMachine.Mode.CMD_LINE, VimStateMachine.SubMode.NONE);
ExEntryPanel panel = ExEntryPanel.getInstance();
panel.activate(((IjVimEditor) editor).getEditor(), ((IjExecutionContext) context).getContext(), ":", initText, 1);
panel.activate(((IjVimEditor) editor).getEditor(), ((IjExecutionContext) context).getContext(), ":", initText, cmd.getCount());
}
@Override
@@ -108,7 +108,7 @@ public class ProcessGroup extends VimProcessGroupBase {
return true;
}
else {
CommandState.getInstance(editor).popModes();
VimStateMachine.getInstance(editor).popModes();
KeyHandler.getInstance().reset(editor);
return false;
}
@@ -119,11 +119,11 @@ public class ProcessGroup extends VimProcessGroupBase {
panel.deactivate(true);
boolean res = true;
try {
CommandState.getInstance(editor).popModes();
VimStateMachine.getInstance(editor).popModes();
logger.debug("processing command");
final String text = panel.getText();
String text = panel.getText();
if (!panel.getLabel().equals(":")) {
// Search is handled via Argument.Type.EX_STRING. Although ProcessExEntryAction is registered as the handler for
@@ -134,7 +134,15 @@ public class ProcessGroup extends VimProcessGroupBase {
if (logger.isDebugEnabled()) logger.debug("swing=" + SwingUtilities.isEventDispatchThread());
VimInjectorKt.getInjector().getVimscriptExecutor().execute(text, editor, context, skipHistory(editor), true, CommandLineVimLContext.INSTANCE);
int repeat = 1;
if (text.contains("raction ")) {
text = text.replace("raction ", "action ");
repeat = panel.getCount();
}
for (int i = 0; i < repeat; i++) {
VimInjectorKt.getInjector().getVimscriptExecutor().execute(text, editor, context, skipHistory(editor), true, CommandLineVimLContext.INSTANCE);
}
}
catch (ExException e) {
VimPlugin.showMessage(e.getMessage());
@@ -152,11 +160,11 @@ public class ProcessGroup extends VimProcessGroupBase {
// commands executed from map command / macro should not be added to history
private boolean skipHistory(VimEditor editor) {
return CommandState.getInstance(editor).getMappingState().isExecutingMap() || injector.getMacro().isExecutingMacro();
return VimStateMachine.getInstance(editor).getMappingState().isExecutingMap() || injector.getMacro().isExecutingMacro();
}
public void cancelExEntry(final @NotNull VimEditor editor, boolean resetCaret) {
CommandState.getInstance(editor).popModes();
VimStateMachine.getInstance(editor).popModes();
KeyHandler.getInstance().reset(editor);
ExEntryPanel panel = ExEntryPanel.getInstance();
panel.deactivate(true, resetCaret);
@@ -165,14 +173,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) + "!";
CommandState.getInstance(editor).pushModes(CommandState.Mode.CMD_LINE, CommandState.SubMode.NONE);
VimStateMachine.getInstance(editor).pushModes(VimStateMachine.Mode.CMD_LINE, VimStateMachine.SubMode.NONE);
ExEntryPanel panel = ExEntryPanel.getInstance();
panel.activate(((IjVimEditor) editor).getEditor(), ((IjExecutionContext) context).getContext(), ":", initText, 1);
}
private @NotNull String getRange(Editor editor, @NotNull Command cmd) {
String initText = "";
if (CommandState.getInstance(new IjVimEditor(editor)).getMode() == CommandState.Mode.VISUAL) {
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
initText = "'<,'>";
}
else if (cmd.getRawCount() > 0) {

View File

@@ -34,7 +34,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimCaret
import com.maddyhome.idea.vim.api.VimEditor
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.SelectionType
import com.maddyhome.idea.vim.command.isBlock
import com.maddyhome.idea.vim.command.isChar
@@ -75,7 +75,7 @@ class PutGroup : VimPutBase() {
additionalData: Map<String, Any>,
) {
val visualSelection = data.visualSelection
val subMode = visualSelection?.typeInEditor?.toSubMode() ?: CommandState.SubMode.NONE
val subMode = visualSelection?.typeInEditor?.toSubMode() ?: VimStateMachine.SubMode.NONE
if (OptionConstants.clipboard_ideaput in (
injector.optionService
.getOptionValue(OptionScope.GLOBAL, OptionConstants.clipboardName) as VimString
@@ -97,7 +97,22 @@ class PutGroup : VimPutBase() {
EditorHelper.getOrderedCaretsList(editor.ij).map { IjVimCaret(it) }
}
injector.application.runWriteAction {
myCarets.forEach { caret -> putForCaret(editor, caret, data, additionalData, context, text) }
val singleCaret = myCarets.singleOrNull()
if (singleCaret != null) {
putForCaret(editor, singleCaret, data, additionalData, context, text)
}
else {
val lines = text.text.split('\n')
if (lines.size != myCarets.size) {
myCarets.forEach { caret -> putForCaret(editor, caret, data, additionalData, context, text) }
}
else {
myCarets.asReversed().forEachIndexed { index, caret ->
val line = ProcessedTextData(lines[index], text.typeInRegister, text.transferableData)
putForCaret(editor, caret, data, additionalData, context, line)
}
}
}
}
}
@@ -113,7 +128,7 @@ class PutGroup : VimPutBase() {
val startOffsets = prepareDocumentAndGetStartOffsets(editor, caret, text.typeInRegister, data, additionalData)
startOffsets.forEach { startOffset ->
val subMode = data.visualSelection?.typeInEditor?.toSubMode() ?: CommandState.SubMode.NONE
val subMode = data.visualSelection?.typeInEditor?.toSubMode() ?: VimStateMachine.SubMode.NONE
val endOffset = putTextInternal(
editor, caret, context, text.text, text.typeInRegister, subMode,
startOffset, data.count, data.indent, data.caretAfterInsertedText
@@ -229,13 +244,13 @@ class PutGroup : VimPutBase() {
}
private fun putTextViaIde(
pasteProvider: PasteProvider,
vimEditor: VimEditor,
vimContext: ExecutionContext,
text: ProcessedTextData,
subMode: CommandState.SubMode,
data: PutData,
additionalData: Map<String, Any>,
pasteProvider: PasteProvider,
vimEditor: VimEditor,
vimContext: ExecutionContext,
text: ProcessedTextData,
subMode: VimStateMachine.SubMode,
data: PutData,
additionalData: Map<String, Any>,
) {
val editor = (vimEditor as IjVimEditor).editor
val context = vimContext.context as DataContext

View File

@@ -23,9 +23,9 @@ import com.intellij.openapi.diagnostic.trace
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.EditorDataContext
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.helper.exitSelectMode
import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.helper.hasVisualSelection
@@ -35,7 +35,7 @@ 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.editorMode
import com.maddyhome.idea.vim.helper.popAllModes
import com.maddyhome.idea.vim.listener.VimListenerManager
import com.maddyhome.idea.vim.newapi.IjVimEditor
@@ -58,7 +58,7 @@ object IdeaSelectionControl {
editor: Editor,
selectionSource: VimListenerManager.SelectionSource = VimListenerManager.SelectionSource.OTHER,
) {
VimVisualTimer.singleTask(editor.mode) { initialMode ->
VimVisualTimer.singleTask(editor.editorMode) { initialMode ->
if (editor.isIdeaVimDisabledHere) return@singleTask
@@ -80,13 +80,13 @@ object IdeaSelectionControl {
return@singleTask
}
logger.debug("Some carets have selection. State before adjustment: ${editor.vim.commandState.toSimpleString()}")
logger.debug("Some carets have selection. State before adjustment: ${editor.vim.vimStateMachine.toSimpleString()}")
editor.popAllModes()
activateMode(editor, chooseSelectionMode(editor, selectionSource, true))
} else {
logger.debug("None of carets have selection. State before adjustment: ${editor.vim.commandState.toSimpleString()}")
logger.debug("None of carets have selection. State before adjustment: ${editor.vim.vimStateMachine.toSimpleString()}")
if (editor.inVisualMode) editor.exitVisualMode()
if (editor.inSelectMode) editor.exitSelectMode(false)
@@ -96,7 +96,7 @@ object IdeaSelectionControl {
}
KeyHandler.getInstance().reset(editor.vim)
logger.debug("${editor.mode} is enabled")
logger.debug("${editor.editorMode} is enabled")
}
}
@@ -110,68 +110,68 @@ 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): CommandState.Mode {
fun predictMode(editor: Editor, selectionSource: VimListenerManager.SelectionSource): VimStateMachine.Mode {
if (editor.selectionModel.hasSelection(true)) {
if (dontChangeMode(editor)) return editor.mode
if (dontChangeMode(editor)) return editor.editorMode
return chooseSelectionMode(editor, selectionSource, false)
} else {
return chooseNonSelectionMode(editor)
}
}
private fun activateMode(editor: Editor, mode: CommandState.Mode) {
private fun activateMode(editor: Editor, mode: VimStateMachine.Mode) {
when (mode) {
CommandState.Mode.VISUAL -> VimPlugin.getVisualMotion()
VimStateMachine.Mode.VISUAL -> VimPlugin.getVisualMotion()
.enterVisualMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
CommandState.Mode.SELECT -> VimPlugin.getVisualMotion()
VimStateMachine.Mode.SELECT -> VimPlugin.getVisualMotion()
.enterSelectMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
CommandState.Mode.INSERT -> VimPlugin.getChange().insertBeforeCursor(
VimStateMachine.Mode.INSERT -> VimPlugin.getChange().insertBeforeCursor(
editor.vim,
EditorDataContext.init(editor).vim
)
CommandState.Mode.COMMAND -> Unit
VimStateMachine.Mode.COMMAND -> Unit
else -> error("Unexpected mode: $mode")
}
}
private fun dontChangeMode(editor: Editor): Boolean =
editor.isTemplateActive() && (IdeaRefactorModeHelper.keepMode() || editor.mode.hasVisualSelection)
editor.isTemplateActive() && (IdeaRefactorModeHelper.keepMode() || editor.editorMode.hasVisualSelection)
private fun chooseNonSelectionMode(editor: Editor): CommandState.Mode {
private fun chooseNonSelectionMode(editor: Editor): VimStateMachine.Mode {
val templateActive = editor.isTemplateActive()
if (templateActive && editor.inNormalMode || editor.inInsertMode) {
return CommandState.Mode.INSERT
return VimStateMachine.Mode.INSERT
}
return CommandState.Mode.COMMAND
return VimStateMachine.Mode.COMMAND
}
private fun chooseSelectionMode(
editor: Editor,
selectionSource: VimListenerManager.SelectionSource,
logReason: Boolean,
): CommandState.Mode {
): VimStateMachine.Mode {
val selectmode = (VimPlugin.getOptionService().getOptionValue(OptionScope.LOCAL(IjVimEditor(editor)), OptionConstants.selectmodeName) as VimString).value
return when {
editor.isOneLineMode -> {
if (logReason) logger.debug("Enter select mode. Reason: one line mode")
CommandState.Mode.SELECT
VimStateMachine.Mode.SELECT
}
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")
CommandState.Mode.SELECT
VimStateMachine.Mode.SELECT
}
editor.isTemplateActive() && IdeaRefactorModeHelper.selectMode() -> {
if (logReason) logger.debug("Enter select mode. Template is active and selectMode has template")
CommandState.Mode.SELECT
VimStateMachine.Mode.SELECT
}
selectionSource == VimListenerManager.SelectionSource.OTHER &&
OptionConstants.selectmode_ideaselection in (VimPlugin.getOptionService().getOptionValue(OptionScope.GLOBAL, OptionConstants.selectmodeName) as VimString).value -> {
if (logReason) logger.debug("Enter select mode. Selection source is OTHER and selectMode has refactoring")
CommandState.Mode.SELECT
VimStateMachine.Mode.SELECT
}
else -> {
if (logReason) logger.debug("Enter visual mode")
CommandState.Mode.VISUAL
VimStateMachine.Mode.VISUAL
}
}
}

View File

@@ -19,7 +19,7 @@
package com.maddyhome.idea.vim.group.visual
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.group.visual.VimVisualTimer.mode
import com.maddyhome.idea.vim.group.visual.VimVisualTimer.singleTask
import com.maddyhome.idea.vim.options.OptionScope
@@ -66,9 +66,9 @@ import javax.swing.Timer
object VimVisualTimer {
var swingTimer: Timer? = null
var mode: CommandState.Mode? = null
var mode: VimStateMachine.Mode? = null
inline fun singleTask(currentMode: CommandState.Mode, crossinline task: (initialMode: CommandState.Mode?) -> Unit) {
inline fun singleTask(currentMode: VimStateMachine.Mode, crossinline task: (initialMode: VimStateMachine.Mode?) -> Unit) {
swingTimer?.stop()
if (mode == null) mode = currentMode
@@ -92,7 +92,7 @@ object VimVisualTimer {
}
}
inline fun timerAction(task: (initialMode: CommandState.Mode?) -> Unit) {
inline fun timerAction(task: (initialMode: VimStateMachine.Mode?) -> Unit) {
task(mode)
swingTimer = null
mode = null

View File

@@ -23,13 +23,13 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.VisualPosition
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.VimMotionGroupBase
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.inBlockSubMode
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.mode
import com.maddyhome.idea.vim.helper.editorMode
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
@@ -108,7 +108,7 @@ val Caret.vimLeadSelectionOffset: Int
}
}
return if (editor.subMode == CommandState.SubMode.VISUAL_LINE) {
return if (editor.subMode == VimStateMachine.SubMode.VISUAL_LINE) {
val selectionStartLine = editor.offsetToLogicalPosition(selectionStart).line
val caretLine = editor.offsetToLogicalPosition(this.offset).line
if (caretLine == selectionStartLine) {
@@ -132,8 +132,8 @@ val Caret.vimLeadSelectionOffset: Int
return caretOffset
}
fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode: CommandState.Mode) {
if (predictedMode != CommandState.Mode.VISUAL) {
fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode: VimStateMachine.Mode) {
if (predictedMode != VimStateMachine.Mode.VISUAL) {
if (!predictedMode.isEndAllowed) {
editor.caretModel.allCarets.forEach { caret ->
val lineEnd = EditorHelper.getLineEndForOffset(editor, caret.offset)
@@ -161,18 +161,18 @@ private fun setVisualSelection(selectionStart: Int, selectionEnd: Int, caret: Ca
val (start, end) = if (selectionStart > selectionEnd) selectionEnd to selectionStart else selectionStart to selectionEnd
val editor = caret.editor
val subMode = editor.subMode
val mode = editor.mode
val mode = editor.editorMode
val vimEditor = IjVimEditor(editor)
when (subMode) {
CommandState.SubMode.VISUAL_CHARACTER -> {
VimStateMachine.SubMode.VISUAL_CHARACTER -> {
val (nativeStart, nativeEnd) = charToNativeSelection(vimEditor, start, end, mode)
caret.vimSetSystemSelectionSilently(nativeStart, nativeEnd)
}
CommandState.SubMode.VISUAL_LINE -> {
VimStateMachine.SubMode.VISUAL_LINE -> {
val (nativeStart, nativeEnd) = lineToNativeSelection(vimEditor, start, end)
caret.vimSetSystemSelectionSilently(nativeStart, nativeEnd)
}
CommandState.SubMode.VISUAL_BLOCK -> {
VimStateMachine.SubMode.VISUAL_BLOCK -> {
editor.caretModel.removeSecondaryCarets()
// Set system selection
@@ -200,7 +200,7 @@ private fun setVisualSelection(selectionStart: Int, selectionEnd: Int, caret: Ca
// Put right caret position for tab character
aCaret.moveToVisualPosition(visualPosition)
}
if (mode != CommandState.Mode.SELECT &&
if (mode != VimStateMachine.Mode.SELECT &&
!EditorHelper.isLineEmpty(editor, line, false) &&
aCaret.offset == aCaret.selectionEnd &&
aCaret.selectionEnd - 1 >= lineStartOffset &&

View File

@@ -19,22 +19,33 @@
package com.maddyhome.idea.vim.group.visual
import com.intellij.find.FindManager
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.command.engine
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim
/**
* @author Alex Plate
*/
class VisualMotionGroup : VimVisualMotionGroupBase() {
override fun autodetectVisualSubmode(editor: VimEditor): CommandState.SubMode {
override fun autodetectVisualSubmode(editor: VimEditor): VimStateMachine.SubMode {
// IJ specific. See https://youtrack.jetbrains.com/issue/VIM-1924.
val project = editor.ij.project
if (project != null && FindManager.getInstance(project).selectNextOccurrenceWasPerformed()) {
return CommandState.SubMode.VISUAL_CHARACTER
return VimStateMachine.SubMode.VISUAL_CHARACTER
}
return super.autodetectVisualSubmode(editor)
}
/**
* COMPATIBILITY-LAYER: Added a method
*/
fun enterVisualMode(editor: Editor, subMode: CommandState.SubMode? = null): Boolean {
return this.enterVisualMode(editor.vim, subMode?.engine)
}
}

View File

@@ -21,7 +21,7 @@ package com.maddyhome.idea.vim.handler
import com.intellij.serviceContainer.BaseKeyedLazyInstance
import com.intellij.util.SmartList
import com.intellij.util.xmlb.annotations.Attribute
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.MappingMode
import javax.swing.KeyStroke
/**

View File

@@ -23,7 +23,7 @@ import com.intellij.openapi.editor.CaretVisualAttributes
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionChangeListener
import com.maddyhome.idea.vim.options.helpers.GuiCursorMode
@@ -75,7 +75,7 @@ object GuicursorChangeListener : OptionChangeListener<VimDataType> {
}
private fun Editor.guicursorMode(): GuiCursorMode {
if (this.vim.commandState.isReplaceCharacter) {
if (this.vim.vimStateMachine.isReplaceCharacter) {
// Can be true for NORMAL and VISUAL
return GuiCursorMode.REPLACE
}
@@ -84,18 +84,18 @@ private fun Editor.guicursorMode(): GuiCursorMode {
// 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 (mode) {
CommandState.Mode.COMMAND -> GuiCursorMode.NORMAL
CommandState.Mode.VISUAL -> GuiCursorMode.VISUAL // TODO: VISUAL_EXCLUSIVE
CommandState.Mode.SELECT -> GuiCursorMode.INSERT
CommandState.Mode.INSERT -> GuiCursorMode.INSERT
CommandState.Mode.OP_PENDING -> GuiCursorMode.OP_PENDING
CommandState.Mode.REPLACE -> GuiCursorMode.REPLACE
return when (editorMode) {
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
CommandState.Mode.CMD_LINE -> GuiCursorMode.CMD_LINE
CommandState.Mode.INSERT_NORMAL -> GuiCursorMode.NORMAL
CommandState.Mode.INSERT_VISUAL -> GuiCursorMode.VISUAL
CommandState.Mode.INSERT_SELECT -> GuiCursorMode.INSERT
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
}
}

View File

@@ -34,7 +34,7 @@ class CommandLineHelper : VimCommandLineHelper {
override fun inputString(vimEditor: VimEditor, prompt: String, finishOn: Char?): String? {
val editor = vimEditor.ij
if (vimEditor.commandState.isDotRepeatInProgress) {
if (vimEditor.vimStateMachine.isDotRepeatInProgress) {
val input = Extension.consumeString()
return input ?: error("Not enough strings saved: ${Extension.lastExtensionHandler}")
}

View File

@@ -23,89 +23,104 @@ package com.maddyhome.idea.vim.helper
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.api.VimEditor
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
val Editor.isEndAllowed: Boolean
get() = when (this.mode) {
CommandState.Mode.INSERT, CommandState.Mode.VISUAL, CommandState.Mode.SELECT, CommandState.Mode.INSERT_VISUAL, CommandState.Mode.INSERT_SELECT -> true
CommandState.Mode.COMMAND, CommandState.Mode.CMD_LINE, CommandState.Mode.REPLACE, CommandState.Mode.OP_PENDING, CommandState.Mode.INSERT_NORMAL -> {
get() = when (this.editorMode) {
VimStateMachine.Mode.INSERT, VimStateMachine.Mode.VISUAL, VimStateMachine.Mode.SELECT, VimStateMachine.Mode.INSERT_VISUAL, VimStateMachine.Mode.INSERT_SELECT -> true
VimStateMachine.Mode.COMMAND, VimStateMachine.Mode.CMD_LINE, VimStateMachine.Mode.REPLACE, VimStateMachine.Mode.OP_PENDING, VimStateMachine.Mode.INSERT_NORMAL -> {
// One day we'll use a proper insert_normal mode
if (this.mode.inSingleMode) true else usesVirtualSpace
if (this.editorMode.inSingleMode) true else usesVirtualSpace
}
}
val CommandState.Mode.isEndAllowedIgnoringOnemore: Boolean
val VimStateMachine.Mode.isEndAllowedIgnoringOnemore: Boolean
get() = 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 -> false
CommandState.Mode.INSERT_NORMAL -> false
CommandState.Mode.INSERT_VISUAL -> true
CommandState.Mode.INSERT_SELECT -> true
VimStateMachine.Mode.INSERT, VimStateMachine.Mode.VISUAL, VimStateMachine.Mode.SELECT -> true
VimStateMachine.Mode.COMMAND, VimStateMachine.Mode.CMD_LINE, VimStateMachine.Mode.REPLACE, VimStateMachine.Mode.OP_PENDING -> false
VimStateMachine.Mode.INSERT_NORMAL -> false
VimStateMachine.Mode.INSERT_VISUAL -> true
VimStateMachine.Mode.INSERT_SELECT -> true
}
val CommandState.Mode.hasVisualSelection
val VimStateMachine.Mode.hasVisualSelection
get() = when (this) {
CommandState.Mode.VISUAL, CommandState.Mode.SELECT -> true
CommandState.Mode.REPLACE, CommandState.Mode.CMD_LINE, CommandState.Mode.COMMAND, CommandState.Mode.INSERT, CommandState.Mode.OP_PENDING -> false
CommandState.Mode.INSERT_NORMAL -> false
CommandState.Mode.INSERT_VISUAL -> true
CommandState.Mode.INSERT_SELECT -> true
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
}
val Editor.editorMode
get() = this.vim.vimStateMachine.mode
/**
* COMPATIBILITY-LAYER: New method
*/
val Editor.mode
get() = this.vim.commandState.mode
get() = this.vim.vimStateMachine.mode.ij
/**
* COMPATIBILITY-LAYER: New method
*/
val CommandState.Mode.isEndAllowed: Boolean
get() = this.engine.isEndAllowed
var Editor.subMode
get() = this.vim.commandState.subMode
get() = this.vim.vimStateMachine.subMode
set(value) {
this.vim.commandState.subMode = value
this.vim.vimStateMachine.subMode = value
}
@get:JvmName("inNormalMode")
val Editor.inNormalMode
get() = this.mode.inNormalMode
get() = this.editorMode.inNormalMode
@get:JvmName("inNormalMode")
val CommandState.Mode.inNormalMode
get() = this == CommandState.Mode.COMMAND || this == CommandState.Mode.INSERT_NORMAL
val VimStateMachine.Mode.inNormalMode
get() = this == VimStateMachine.Mode.COMMAND || this == VimStateMachine.Mode.INSERT_NORMAL
@get:JvmName("inInsertMode")
val Editor.inInsertMode
get() = this.mode == CommandState.Mode.INSERT || this.mode == CommandState.Mode.REPLACE
get() = this.editorMode == VimStateMachine.Mode.INSERT || this.editorMode == VimStateMachine.Mode.REPLACE
@get:JvmName("inRepeatMode")
val Editor.inRepeatMode
get() = this.vim.commandState.isDotRepeatInProgress
get() = this.vim.vimStateMachine.isDotRepeatInProgress
@get:JvmName("inVisualMode")
val Editor.inVisualMode
get() = this.mode.inVisualMode
get() = this.editorMode.inVisualMode
@get:JvmName("inSelectMode")
val Editor.inSelectMode
get() = this.mode == CommandState.Mode.SELECT || this.mode == CommandState.Mode.INSERT_SELECT
get() = this.editorMode == VimStateMachine.Mode.SELECT || this.editorMode == VimStateMachine.Mode.INSERT_SELECT
val VimEditor.inSelectMode
get() = this.mode == CommandState.Mode.SELECT || this.mode == CommandState.Mode.INSERT_SELECT
get() = this.mode == VimStateMachine.Mode.SELECT || this.mode == VimStateMachine.Mode.INSERT_SELECT
@get:JvmName("inBlockSubMode")
val Editor.inBlockSubMode
get() = this.subMode == CommandState.SubMode.VISUAL_BLOCK
get() = this.subMode == VimStateMachine.SubMode.VISUAL_BLOCK
@get:JvmName("inSingleCommandMode")
val Editor.inSingleCommandMode: Boolean
get() = this.mode.inSingleMode
get() = this.editorMode.inSingleMode
@get:JvmName("inSingleMode")
val CommandState.Mode.inSingleMode: Boolean
val VimStateMachine.Mode.inSingleMode: Boolean
get() = when (this) {
CommandState.Mode.INSERT_NORMAL, CommandState.Mode.INSERT_SELECT, CommandState.Mode.INSERT_VISUAL -> true
VimStateMachine.Mode.INSERT_NORMAL, VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.Mode.INSERT_VISUAL -> true
else -> false
}
@get:JvmName("inSingleNormalMode")
val CommandState.Mode.inSingleNormalMode: Boolean
val VimStateMachine.Mode.inSingleNormalMode: Boolean
get() = when (this) {
CommandState.Mode.INSERT_NORMAL -> true
VimStateMachine.Mode.INSERT_NORMAL -> true
else -> false
}

View File

@@ -152,6 +152,13 @@ public class EditorHelper {
: VimInjectorKt.getInjector().getEngineEditorHelper().logicalLineToVisualLine(editor, count - 1) + 1;
}
/**
* COMPATIBILITY-LAYER: Created a function
*/
public static int getVisualLineCount(final @NotNull Editor editor) {
return getVisualLineCount(new IjVimEditor(editor));
}
/**
* Gets the number of actual lines in the file
*
@@ -853,7 +860,7 @@ public class EditorHelper {
if (inlayAwareOffset == vimLastColumn) return vimLastColumn;
Editor editor = caret.getEditor();
boolean isEndAllowed = CommandStateHelper.isEndAllowedIgnoringOnemore(CommandStateHelper.getMode(editor));
boolean isEndAllowed = CommandStateHelper.isEndAllowedIgnoringOnemore(CommandStateHelper.getEditorMode(editor));
final LogicalPosition logicalPosition = caret.getLogicalPosition();
int lastColumn = EditorHelper.lastColumnForLine(editor, logicalPosition.line, isEndAllowed);

View File

@@ -25,7 +25,7 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.common.TextRange
@@ -39,8 +39,8 @@ import com.maddyhome.idea.vim.newapi.vim
* Pop all modes, but leave editor state. E.g. editor selection is not removed.
*/
fun Editor.popAllModes() {
val commandState = this.vim.commandState
while (commandState.mode != CommandState.Mode.COMMAND) {
val commandState = this.vim.vimStateMachine
while (commandState.mode != VimStateMachine.Mode.COMMAND) {
commandState.popModes()
}
}
@@ -63,7 +63,7 @@ fun Editor.exitVisualMode() {
VimPlugin.getMark().setVisualSelectionMarks(this.vim, TextRange(vimSelectionStart, primaryCaret.offset))
this.caretModel.allCarets.forEach { it.vimSelectionStartClear() }
this.vim.commandState.popModes()
this.vim.vimStateMachine.popModes()
}
}
@@ -71,7 +71,7 @@ fun Editor.exitVisualMode() {
fun Editor.exitSelectMode(adjustCaretPosition: Boolean) {
if (!this.inSelectMode) return
this.vim.commandState.popModes()
this.vim.vimStateMachine.popModes()
SelectionVimListenerSuppressor.lock().use {
this.caretModel.allCarets.forEach {
it.removeSelection()
@@ -91,7 +91,7 @@ fun Editor.exitSelectMode(adjustCaretPosition: Boolean) {
fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) {
if (!this.inSelectMode) return
this.commandState.popModes()
this.vimStateMachine.popModes()
SelectionVimListenerSuppressor.lock().use {
this.carets().forEach { vimCaret ->
val caret = (vimCaret as IjVimCaret).caret

View File

@@ -31,7 +31,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.VimStateMachine;
import com.maddyhome.idea.vim.common.CharacterPosition;
import com.maddyhome.idea.vim.common.Direction;
import com.maddyhome.idea.vim.common.TextRange;
@@ -893,8 +893,8 @@ public class SearchHelper {
selectionEndWithoutNewline++;
}
final CommandState.Mode mode = CommandState.getInstance(new IjVimEditor(editor)).getMode();
if (mode == CommandState.Mode.VISUAL) {
final VimStateMachine.Mode mode = VimStateMachine.getInstance(new IjVimEditor(editor)).getMode();
if (mode == VimStateMachine.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

@@ -0,0 +1,39 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2022 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.helper;
import javax.swing.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static com.maddyhome.idea.vim.api.VimInjectorKt.injector;
/**
* COMPATIBILITY-LAYER: Created a helper class
*/
public class StringHelper {
public static List<KeyStroke> parseKeys(String string) {
return injector.getParser().parseKeys(string);
}
public static List<KeyStroke> parseKeys(String... string) {
return Arrays.stream(string).flatMap(o -> injector.getParser().parseKeys(o).stream()).collect(Collectors.toList());
}
}

View File

@@ -25,9 +25,7 @@ import com.intellij.openapi.command.undo.UndoManager
import com.intellij.openapi.components.Service
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.common.ChangesListener
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
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.options.OptionScope
@@ -49,7 +47,7 @@ class UndoRedoHelper : UndoRedoBase() {
SelectionVimListenerSuppressor.lock().use { undoManager.undo(fileEditor) }
} else {
val editor = CommonDataKeys.EDITOR.getData(context.ij)?.vim
performUntilFileChanges(editor, { undoManager.isUndoAvailable(fileEditor) }, { undoManager.undo(fileEditor) })
undoManager.undo(fileEditor)
editor?.carets()?.forEach {
val ijCaret = it.ij
val hasSelection = ijCaret.hasSelection()
@@ -75,30 +73,14 @@ class UndoRedoHelper : UndoRedoBase() {
SelectionVimListenerSuppressor.lock().use { undoManager.redo(fileEditor) }
} else {
val editor = CommonDataKeys.EDITOR.getData(context.ij)?.vim
performUntilFileChanges(editor, { undoManager.isRedoAvailable(fileEditor) }, { undoManager.redo(fileEditor) })
undoManager.redo(fileEditor)
if (editor?.primaryCaret()?.ij?.hasSelection() == true) {
undoManager.redo(fileEditor)
}
editor?.carets()?.forEach { it.ij.removeSelection() }
}
return true
}
return false
}
private fun performUntilFileChanges(editor: IjVimEditor?, check: () -> Boolean, action: Runnable) {
if (editor == null) return
val vimDocument = editor.document
val changeListener = object : ChangesListener {
var hasChanged = false
override fun documentChanged(change: ChangesListener.Change) {
hasChanged = true
}
}
vimDocument.addChangeListener(changeListener)
while (check() && !changeListener.hasChanged) {
action.run()
}
vimDocument.removeChangeListener(changeListener)
}
}

View File

@@ -27,7 +27,7 @@ import com.intellij.openapi.editor.RangeMarker
import com.intellij.openapi.editor.markup.RangeHighlighter
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.UserDataHolder
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.group.visual.VisualChange
@@ -77,7 +77,7 @@ var Caret.vimInsertStart: RangeMarker by userDataOr {
// ------------------ Editor
fun unInitializeEditor(editor: Editor) {
editor.vimLastSelectionType = null
editor.vimCommandState = null
editor.vimStateMachine = null
editor.vimMorePanel = null
editor.vimExOutput = null
editor.vimLastHighlighters = null
@@ -91,7 +91,7 @@ var Editor.vimIncsearchCurrentMatchOffset: Int? by userData()
* @see :help visualmode()
*/
var Editor.vimLastSelectionType: SelectionType? by userData()
var Editor.vimCommandState: CommandState? by userData()
var Editor.vimStateMachine: VimStateMachine? by userData()
var Editor.vimEditorGroup: Boolean by userDataOr { false }
var Editor.vimLineNumbersInitialState: Boolean by userDataOr { false }
var Editor.vimHasRelativeLineNumbersInstalled: Boolean by userDataOr { false }
@@ -103,7 +103,7 @@ var Editor.vimTestInputModel: TestInputModel? by userData()
* Checks whether a keeping visual mode visual operator action is performed on editor.
*/
var Editor.vimKeepingVisualOperatorAction: Boolean by userDataOr { false }
var Editor.vimChangeActionSwitchMode: CommandState.Mode? by userData()
var Editor.vimChangeActionSwitchMode: VimStateMachine.Mode? by userData()
/**
* Function for delegated properties.

View File

@@ -19,8 +19,10 @@
package com.maddyhome.idea.vim.listener
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.codeInsight.lookup.LookupManager
import com.intellij.codeInsight.lookup.LookupManagerListener
import com.intellij.codeInsight.lookup.impl.LookupImpl
import com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction
import com.intellij.codeInsight.template.Template
import com.intellij.codeInsight.template.TemplateEditingAdapter
import com.intellij.codeInsight.template.TemplateManagerListener
@@ -35,12 +37,12 @@ import com.intellij.openapi.actionSystem.ex.AnActionListener
import com.intellij.openapi.actionSystem.impl.ProxyShortcutSet
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.DumbAwareToggleAction
import com.intellij.openapi.util.TextRange
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.group.NotificationService
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.EditorDataContext
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.helper.inNormalMode
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.newapi.vim
@@ -49,6 +51,8 @@ import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
import com.maddyhome.idea.vim.vimscript.model.options.helpers.IdeaRefactorModeHelper
import org.jetbrains.annotations.NonNls
import java.awt.event.KeyEvent
import javax.swing.KeyStroke
/**
* @author Alex Plate
@@ -60,6 +64,8 @@ object IdeaSpecifics {
private val surrounderAction =
"com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler\$InvokeSurrounderAction"
private var editor: Editor? = null
private var completionPrevDocumentLength: Int? = null
private var completionPrevDocumentOffset: Int? = null
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
if (!VimPlugin.isEnabled()) return
@@ -68,19 +74,52 @@ object IdeaSpecifics {
editor = hostEditor
}
//region Track action id
if (VimPlugin.getOptionService().isSet(OptionScope.GLOBAL, OptionConstants.trackactionidsName)) {
if (action !is NotificationService.ActionIdNotifier.CopyActionId && action !is NotificationService.ActionIdNotifier.StopTracking) {
val id: String? = ActionManager.getInstance().getId(action) ?: (action.shortcutSet as? ProxyShortcutSet)?.actionId
VimPlugin.getNotifications(dataContext.getData(CommonDataKeys.PROJECT)).notifyActionId(id)
val id: String? = ActionManager.getInstance().getId(action) ?: (action.shortcutSet as? ProxyShortcutSet)?.actionId
VimPlugin.getNotifications(dataContext.getData(CommonDataKeys.PROJECT)).notifyActionId(id)
}
if (hostEditor != null && action is ChooseItemAction && hostEditor.vimStateMachine?.isRecording == true) {
val lookup = LookupManager.getActiveLookup(hostEditor)
if (lookup != null) {
val charsToRemove = hostEditor.caretModel.primaryCaret.offset - lookup.lookupStart
val register = VimPlugin.getRegister()
val backSpace = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)
repeat(charsToRemove) {
register.recordKeyStroke(backSpace)
}
completionPrevDocumentLength = hostEditor.document.textLength - charsToRemove
completionPrevDocumentOffset = lookup.lookupStart
}
}
//endregion
}
override fun afterActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
if (!VimPlugin.isEnabled()) return
val editor = editor
if (editor != null && action is ChooseItemAction && editor.vimStateMachine?.isRecording == true) {
val prevDocumentLength = completionPrevDocumentLength
val prevDocumentOffset = completionPrevDocumentOffset
if (prevDocumentLength != null && prevDocumentOffset != null) {
val register = VimPlugin.getRegister()
val addedTextLength = editor.document.textLength - prevDocumentLength
val caretShift = addedTextLength - (editor.caretModel.primaryCaret.offset - prevDocumentOffset)
val leftArrow = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)
register.recordText(editor.document.getText(TextRange(prevDocumentOffset, prevDocumentOffset + addedTextLength)))
repeat(caretShift.coerceAtLeast(0)) {
register.recordKeyStroke(leftArrow)
}
}
this.completionPrevDocumentLength = null
this.completionPrevDocumentOffset = null
}
//region Enter insert mode after surround with if
if (surrounderAction == action.javaClass.name && surrounderItems.any {
action.templatePresentation.text.endsWith(
@@ -89,8 +128,8 @@ object IdeaSpecifics {
}
) {
editor?.let {
val commandState = it.vim.commandState
while (commandState.mode != CommandState.Mode.COMMAND) {
val commandState = it.vim.vimStateMachine
while (commandState.mode != VimStateMachine.Mode.COMMAND) {
commandState.popModes()
}
VimPlugin.getChange().insertBeforeCursor(it.vim, dataContext.vim)
@@ -99,7 +138,7 @@ object IdeaSpecifics {
}
//endregion
editor = null
this.editor = null
}
}

View File

@@ -44,7 +44,7 @@ import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimKeyListener
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.VimTypedActionHandler
import com.maddyhome.idea.vim.command.CommandState
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
@@ -425,7 +425,7 @@ object VimListenerManager {
ExOutputModel.getInstance(editor).clear()
val caretModel = editor.caretModel
if (editor.subMode != CommandState.SubMode.NONE) {
if (editor.subMode != VimStateMachine.SubMode.NONE) {
caretModel.removeSecondaryCarets()
}

View File

@@ -32,7 +32,7 @@ import com.maddyhome.idea.vim.api.VimChangeGroupBase
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.VimMotionGroupBase
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.SelectionType
import com.maddyhome.idea.vim.common.EditorLine
import com.maddyhome.idea.vim.common.IndentConfig
@@ -103,7 +103,7 @@ fun changeRange(
if (type == SelectionType.BLOCK_WISE) {
VimPlugin.getChange().setInsertRepeat(lines, col, false)
}
editor.vimChangeActionSwitchMode = CommandState.Mode.INSERT
editor.vimChangeActionSwitchMode = VimStateMachine.Mode.INSERT
}
} else {
VimPlugin.getChange().insertBeforeCursor(editor.vim, context.vim)
@@ -158,9 +158,9 @@ fun deleteRange(
fun insertLineAround(editor: VimEditor, context: ExecutionContext, shift: Int) {
val project = (editor as IjVimEditor).editor.project
VimPlugin.getChange().initInsert(editor, context, CommandState.Mode.INSERT)
VimPlugin.getChange().initInsert(editor, context, VimStateMachine.Mode.INSERT)
if (!CommandState.getInstance(editor).isDotRepeatInProgress) {
if (!VimStateMachine.getInstance(editor).isDotRepeatInProgress) {
for (vimCaret in editor.carets()) {
val caret = (vimCaret as IjVimCaret).caret
val line = vimCaret.getLine()

View File

@@ -38,7 +38,7 @@ import com.maddyhome.idea.vim.api.VimLogicalPosition
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.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.common.EditorLine
@@ -72,7 +72,7 @@ class IjVimEditor(editor: Editor) : MutableLinearEditor() {
val originalEditor = editor
override val lfMakesNewLine: Boolean = true
override var vimChangeActionSwitchMode: CommandState.Mode?
override var vimChangeActionSwitchMode: VimStateMachine.Mode?
get() = editor.vimChangeActionSwitchMode
set(value) {
editor.vimChangeActionSwitchMode = value

View File

@@ -3,6 +3,7 @@ package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.components.service
import com.intellij.openapi.components.serviceIfCreated
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.api.EngineEditorHelper
import com.maddyhome.idea.vim.api.ExEntryPanel
import com.maddyhome.idea.vim.api.ExecutionContextManager
@@ -39,7 +40,7 @@ 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.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.common.VimMachine
import com.maddyhome.idea.vim.diagnostic.VimLogger
import com.maddyhome.idea.vim.ex.ExOutputModel
@@ -63,7 +64,7 @@ import com.maddyhome.idea.vim.helper.IjEditorHelper
import com.maddyhome.idea.vim.helper.IjVimStringParser
import com.maddyhome.idea.vim.helper.UndoRedoHelper
import com.maddyhome.idea.vim.helper.VimCommandLineHelper
import com.maddyhome.idea.vim.helper.vimCommandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.history.VimHistory
import com.maddyhome.idea.vim.macro.VimMacro
import com.maddyhome.idea.vim.mark.VimMarkGroup
@@ -179,15 +180,23 @@ class IjVimInjector : VimInjectorBase() {
override val vimStorageService: VimStorageService
get() = service()
override fun commandStateFor(editor: VimEditor): CommandState {
var res = editor.ij.vimCommandState
override fun commandStateFor(editor: VimEditor): VimStateMachine {
var res = editor.ij.vimStateMachine
if (res == null) {
res = CommandState(editor)
editor.ij.vimCommandState = res
res = VimStateMachine(editor)
editor.ij.vimStateMachine = res
}
return res
}
override fun commandStateFor(editor: Any): VimStateMachine {
return when (editor) {
is VimEditor -> this.commandStateFor(editor)
is Editor -> this.commandStateFor(IjVimEditor(editor))
else -> error("Unexpected type: $editor")
}
}
override val engineEditorHelper: EngineEditorHelper
get() = service<IjEditorHelper>()
override val editorGroup: VimEditorGroup

View File

@@ -0,0 +1,53 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2022 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.option
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionConstants.Companion.ignorecaseName
import com.maddyhome.idea.vim.options.OptionConstants.Companion.smartcaseName
import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.options.helpers.KeywordOptionHelper
import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService
/**
* COMPATIBILITY-LAYER: Added a class and package
*/
object OptionsManager {
val ignorecase: ToggleOption
get() = (injector.optionService as IjVimOptionService).getRawOption(ignorecaseName) as ToggleOption
val smartcase: ToggleOption
get() = (injector.optionService as IjVimOptionService).getRawOption(smartcaseName) as ToggleOption
val iskeyword: KeywordOption
get() = KeywordOption(KeywordOptionHelper)
}
class KeywordOption(val helper: KeywordOptionHelper) {
fun toRegex(): List<String> {
return helper.toRegex()
}
}
object StrictMode {
fun fail(message: String) {
if (injector.optionService.isSet(OptionScope.GLOBAL, OptionConstants.ideastrictmodeName)) {
error(message)
}
}
}

View File

@@ -4,7 +4,7 @@ import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.util.containers.MultiMap
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.key.MappingOwner
import com.maddyhome.idea.vim.key.ToKeysMappingInfo

View File

@@ -20,7 +20,7 @@ package com.maddyhome.idea.vim.ui
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.helper.isCloseKeyStroke
import java.awt.KeyEventDispatcher
import java.awt.KeyboardFocusManager
@@ -62,7 +62,7 @@ object ModalEntry {
} else {
return true
}
if (editor.commandState.isRecording) {
if (editor.vimStateMachine.isRecording) {
KeyHandler.getInstance().modalEntryKeys += stroke
}
if (!processor(stroke)) {

View File

@@ -33,7 +33,7 @@ import com.intellij.util.Consumer
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.helper.EngineStringHelper
import com.maddyhome.idea.vim.helper.VimNlsSafe
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionChangeListener
import com.maddyhome.idea.vim.options.OptionConstants
@@ -70,7 +70,7 @@ object ShowCmd {
fun getFullText(editor: Editor?): String {
if (!VimPlugin.getOptionService().isSet(OptionScope.GLOBAL, OptionConstants.showcmdName) || editor == null || editor.isDisposed) return ""
val editorState = editor.vim.commandState
val editorState = editor.vim.vimStateMachine
return EngineStringHelper.toPrintableCharacters(editorState.commandBuilder.keys + editorState.mappingState.keys)
}
}

View File

@@ -46,4 +46,4 @@ class JoinFunctionHandler : FunctionHandler() {
val secondArgument = argumentValues.getOrNull(1)?.evaluate(editor, context, vimContext) ?: VimString(" ")
return VimString(firstArgument.values.joinToString(secondArgument.asString()) { it.toString() })
}
}
}

View File

@@ -0,0 +1,48 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2021 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.vimscript.model.functions.handlers
import com.intellij.refactoring.rename.inplace.InplaceRefactoring
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler
object RenamingFunctionHandler : FunctionHandler() {
override val name = "renaming"
override val minimumNumberOfArguments = 0
override val maximumNumberOfArguments = 0
override fun doFunction(
argumentValues: List<Expression>,
editor: VimEditor,
context: ExecutionContext,
vimContext: VimLContext,
): VimDataType {
return if (InplaceRefactoring.getActiveInplaceRenamer(editor.ij) == null)
VimInt.ZERO
else
VimInt.ONE
}
}

View File

@@ -41,4 +41,4 @@ class ToupperFunctionHandler : FunctionHandler() {
val argumentString = argumentValues[0].evaluate(editor, context, vimContext).asString()
return VimString(argumentString.uppercase(Locale.getDefault()))
}
}
}

View File

@@ -27,7 +27,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
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.editorMode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
import com.maddyhome.idea.vim.newapi.vim
@@ -42,12 +42,12 @@ object IdeaRefactorModeHelper {
fun correctSelection(editor: Editor) {
val action: () -> Unit = {
if (!editor.mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
if (!editor.editorMode.hasVisualSelection && editor.selectionModel.hasSelection()) {
SelectionVimListenerSuppressor.lock().use {
editor.selectionModel.removeSelection()
}
}
if (editor.mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
if (editor.editorMode.hasVisualSelection && editor.selectionModel.hasSelection()) {
val autodetectedSubmode = VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim)
if (editor.subMode != autodetectedSubmode) {
// Update the submode

View File

@@ -162,7 +162,7 @@ object CommandVisitor : VimscriptBaseVisitor<Command>() {
val ranges = createRange(valueAndOffset.first, valueAndOffset.second, move)
if (ranges == null) {
logger.warn("Could not create a range for node ${ctx.text}")
throw ExException("Could not create a range")
throw ExException("Could not create a range ${ctx.text}")
}
return ranges
}

View File

@@ -22,7 +22,7 @@ import com.intellij.openapi.application.ApplicationNamesInfo
import com.maddyhome.idea.vim.api.VimOptionServiceBase
import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.StringOption
import com.maddyhome.idea.vim.options.ToggleOption
import com.maddyhome.idea.vim.option.ToggleOption
internal class IjVimOptionService : VimOptionServiceBase() {

View File

@@ -14,5 +14,6 @@
<vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.TolowerFunctionHandler" name="tolower"/>
<vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.ToupperFunctionHandler" name="toupper"/>
<vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.JoinFunctionHandler" name="join"/>
<vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.RenamingFunctionHandler" name="renaming"/>
</extensions>
</idea-plugin>
</idea-plugin>

View File

@@ -1,4 +1,4 @@
<idea-plugin url="https://plugins.jetbrains.com/plugin/164" xmlns:xi="http://www.w3.org/2001/XInclude">
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude">
<name>IdeaVim</name>
<id>IdeaVIM</id>
<change-notes><![CDATA[
@@ -65,7 +65,7 @@
<li><a href="https://youtrack.jetbrains.com/issues/VIM">Issue tracker</a>: feature requests and bug reports</li>
</ul>
]]></description>
<version>SNAPSHOT</version>
<version>chylex</version>
<vendor>JetBrains</vendor>
<!-- Please search for "[VERSION UPDATE]" in project in case you update the since-build version -->

View File

@@ -24,7 +24,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
import com.maddyhome.idea.vim.KeyHandler;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.VimStateMachine;
import com.maddyhome.idea.vim.group.visual.VimVisualTimer;
import com.maddyhome.idea.vim.helper.EditorDataContext;
import com.maddyhome.idea.vim.helper.RunnableHelper;
@@ -107,8 +107,8 @@ public abstract class JavaVimTestCase extends JavaCodeInsightFixtureTestCase {
return editor;
}
public void assertMode(@NotNull CommandState.Mode expectedMode) {
final CommandState.Mode mode = CommandState.getInstance(new IjVimEditor(myFixture.getEditor())).getMode();
public void assertMode(@NotNull VimStateMachine.Mode expectedMode) {
final VimStateMachine.Mode mode = VimStateMachine.getInstance(new IjVimEditor(myFixture.getEditor())).getMode();
assertEquals(expectedMode, mode);
}

View File

@@ -28,7 +28,7 @@ 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.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.register.RegisterConstants.ALTERNATE_BUFFER_REGISTER
import com.maddyhome.idea.vim.register.RegisterConstants.BLACK_HOLE_REGISTER
@@ -153,7 +153,7 @@ internal object NeovimTesting {
}
private fun assertMode(editor: Editor) {
val ideavimState = editor.vim.commandState.toVimNotation()
val ideavimState = editor.vim.vimStateMachine.toVimNotation()
val neovimState = neovimApi.mode.get().mode
assertEquals(neovimState, ideavimState)
}

View File

@@ -21,10 +21,10 @@ 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.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.common.CommandNode
import com.maddyhome.idea.vim.common.CommandPartNode
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.handler.ActionBeanClass
import junit.framework.TestCase
import javax.swing.KeyStroke
@@ -33,7 +33,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("l", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(reason = SkipNeovimReason.EDITOR_MODIFICATION)
@@ -44,7 +44,7 @@ class RegisterActionsTest : VimTestCase() {
val keys = injector.parser.parseKeys("jklwB") // just random keys
val before = "I ${c}found it in a legendary land"
val after = "I jklwB${c}found it in a legendary land"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) {
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
VimPlugin.setEnabled(false)
}
}
@@ -54,7 +54,7 @@ class RegisterActionsTest : VimTestCase() {
val keys = injector.parser.parseKeys("l")
val before = "I ${c}found it in a legendary land"
val after = "I f${c}ound it in a legendary land"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) {
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
VimPlugin.setEnabled(false)
VimPlugin.setEnabled(true)
}
@@ -65,7 +65,7 @@ class RegisterActionsTest : VimTestCase() {
val keys = injector.parser.parseKeys("l")
val before = "I ${c}found it in a legendary land"
val after = "I f${c}ound it in a legendary land"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) {
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
VimPlugin.setEnabled(false)
VimPlugin.setEnabled(true)
VimPlugin.setEnabled(true)
@@ -78,7 +78,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(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) {
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
motionRightAction = VIM_ACTIONS_EP.extensions().filter { it.actionId == "VimPreviousTabAction" }.findFirst().get()
assertNotNull(getCommandNode())

View File

@@ -24,9 +24,9 @@ import com.intellij.openapi.editor.LogicalPosition
import com.intellij.testFramework.EditorTestUtil
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.editorMode
import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
@@ -76,11 +76,11 @@ inline fun waitAndAssert(timeInMillis: Int = 1000, condition: () -> Boolean) {
}
fun waitAndAssertMode(
fixture: CodeInsightTestFixture,
mode: CommandState.Mode,
timeInMillis: Int = (VimPlugin.getOptionService().getOptionValue(OptionScope.GLOBAL, OptionConstants.visualdelayName) as VimInt).value + 1000,
fixture: CodeInsightTestFixture,
mode: VimStateMachine.Mode,
timeInMillis: Int = (VimPlugin.getOptionService().getOptionValue(OptionScope.GLOBAL, OptionConstants.visualdelayName) as VimInt).value + 1000,
) {
waitAndAssert(timeInMillis) { fixture.editor.mode == mode }
waitAndAssert(timeInMillis) { fixture.editor.editorMode == mode }
}
fun assertDoesntChange(timeInMillis: Int = 1000, condition: () -> Boolean) {

View File

@@ -50,9 +50,9 @@ 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.CommandState
import com.maddyhome.idea.vim.command.CommandState.SubMode
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.VimStateMachine.SubMode
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ExOutputModel.Companion.getInstance
import com.maddyhome.idea.vim.group.visual.VimVisualTimer.swingTimer
@@ -63,7 +63,7 @@ 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.editorMode
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.key.MappingOwner
import com.maddyhome.idea.vim.key.ToKeysMappingInfo
@@ -439,8 +439,8 @@ abstract class VimTestCase : UsefulTestCase() {
}
}
fun assertMode(expectedMode: CommandState.Mode) {
val mode = myFixture.editor.mode
fun assertMode(expectedMode: VimStateMachine.Mode) {
val mode = myFixture.editor.editorMode
Assert.assertEquals(expectedMode, mode)
}
@@ -505,25 +505,25 @@ abstract class VimTestCase : UsefulTestCase() {
before: String,
after: String,
) {
doTest(keys, before, after, CommandState.Mode.COMMAND, SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, SubMode.NONE)
}
fun doTest(
keys: List<String>,
before: String,
after: String,
modeAfter: CommandState.Mode,
subModeAfter: SubMode,
keys: List<String>,
before: String,
after: String,
modeAfter: VimStateMachine.Mode,
subModeAfter: SubMode,
) {
doTest(keys.joinToString(separator = ""), before, after, modeAfter, subModeAfter)
}
fun doTest(
keys: String,
before: String,
after: String,
modeAfter: CommandState.Mode,
subModeAfter: SubMode,
keys: String,
before: String,
after: String,
modeAfter: VimStateMachine.Mode,
subModeAfter: SubMode,
) {
configureByText(before)
@@ -533,12 +533,12 @@ abstract class VimTestCase : UsefulTestCase() {
}
fun doTest(
keys: String,
before: String,
after: String,
modeAfter: CommandState.Mode,
subModeAfter: SubMode,
fileType: FileType,
keys: String,
before: String,
after: String,
modeAfter: VimStateMachine.Mode,
subModeAfter: SubMode,
fileType: FileType,
) {
configureByText(fileType, before)
@@ -551,12 +551,12 @@ abstract class VimTestCase : UsefulTestCase() {
}
fun doTest(
keys: String,
before: String,
after: String,
modeAfter: CommandState.Mode,
subModeAfter: SubMode,
fileName: String,
keys: String,
before: String,
after: String,
modeAfter: VimStateMachine.Mode,
subModeAfter: SubMode,
fileName: String,
) {
configureByText(fileName, before)
@@ -568,7 +568,7 @@ abstract class VimTestCase : UsefulTestCase() {
NeovimTesting.assertState(myFixture.editor, this)
}
protected fun performTest(keys: String, after: String, modeAfter: CommandState.Mode, subModeAfter: SubMode) {
protected fun performTest(keys: String, after: String, modeAfter: VimStateMachine.Mode, subModeAfter: SubMode) {
typeText(injector.parser.parseKeys(keys))
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
@Suppress("IdeaVimAssertState")
@@ -577,12 +577,12 @@ abstract class VimTestCase : UsefulTestCase() {
}
fun doTest(
keys: List<KeyStroke>,
before: String,
after: String?,
modeAfter: CommandState.Mode,
subModeAfter: SubMode,
afterEditorInitialized: (Editor) -> Unit,
keys: List<KeyStroke>,
before: String,
after: String?,
modeAfter: VimStateMachine.Mode,
subModeAfter: SubMode,
afterEditorInitialized: (Editor) -> Unit,
) {
configureByText(before)
afterEditorInitialized(myFixture.editor)
@@ -597,7 +597,7 @@ abstract class VimTestCase : UsefulTestCase() {
NeovimTesting.setRegister(register, keys, this)
}
protected fun assertState(modeAfter: CommandState.Mode, subModeAfter: SubMode) {
protected fun assertState(modeAfter: VimStateMachine.Mode, subModeAfter: SubMode) {
assertMode(modeAfter)
assertSubMode(subModeAfter)
assertCaretsVisualAttributes()

View File

@@ -20,7 +20,7 @@ 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.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@@ -33,8 +33,8 @@ class ChangeActionTest : VimTestCase() {
// VIM-620 |i_CTRL-O|
fun testInsertSingleCommandAndInserting() {
doTest(
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"), "abc${c}d\n", "abcd12\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"), "abc${c}d\n", "abcd12\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -42,7 +42,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting() {
doTest(
listOf("i", "<C-O>", "o", "123", "<Esc>", "x"),
"abc${c}d\n", "abcd\n12\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"abc${c}d\n", "abcd\n12\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -50,7 +50,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting2() {
doTest(
listOf("i", "<C-O>", "v"),
"12${c}345", "12${s}${c}3${se}45", CommandState.Mode.INSERT_VISUAL, CommandState.SubMode.VISUAL_CHARACTER
"12${c}345", "12${s}${c}3${se}45", VimStateMachine.Mode.INSERT_VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER
)
}
@@ -58,7 +58,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting3() {
doTest(
listOf("i", "<C-O>", "v", "<esc>"),
"12${c}345", "12${c}345", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"12${c}345", "12${c}345", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -66,7 +66,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting4() {
doTest(
listOf("i", "<C-O>", "v", "d"),
"12${c}345", "12${c}45", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"12${c}345", "12${c}45", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -74,7 +74,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting5() {
doTest(
listOf("i", "<C-O>", "v", "<C-G>"),
"12${c}345", "12${s}3${c}${se}45", CommandState.Mode.INSERT_SELECT, CommandState.SubMode.VISUAL_CHARACTER
"12${c}345", "12${s}3${c}${se}45", VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER
)
}
@@ -82,7 +82,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting6() {
doTest(
listOf("i", "<C-O>", "gh"),
"12${c}345", "12${s}3${c}${se}45", CommandState.Mode.INSERT_SELECT, CommandState.SubMode.VISUAL_CHARACTER
"12${c}345", "12${s}3${c}${se}45", VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER
)
}
@@ -90,7 +90,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting7() {
doTest(
listOf("i", "<C-O>", "gh", "<esc>"),
"12${c}345", "123${c}45", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"12${c}345", "123${c}45", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -109,58 +109,58 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommand() {
doTest(
listOf("i", "def", "<C-O>", "d2h", "x"),
"abc$c.\n", "abcdx.\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"abc$c.\n", "abcdx.\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
// VIM-321 |d| |count|
fun testDeleteEmptyRange() {
doTest("d0", "${c}hello\n", "hello\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("d0", "${c}hello\n", "hello\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-157 |~|
fun testToggleCharCase() {
doTest("~~", "${c}hello world\n", "HEllo world\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("~~", "${c}hello world\n", "HEllo world\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-157 |~|
fun testToggleCharCaseLineEnd() {
doTest("~~", "hello wor${c}ld\n", "hello worLD\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("~~", "hello wor${c}ld\n", "hello worLD\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun testToggleCaseMotion() {
doTest("g~w", "${c}FooBar Baz\n", "fOObAR Baz\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("g~w", "${c}FooBar Baz\n", "fOObAR Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun testChangeUpperCase() {
doTest(
"gUw", "${c}FooBar Baz\n", "FOOBAR Baz\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
"gUw", "${c}FooBar Baz\n", "FOOBAR Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
fun testChangeLowerCase() {
doTest("guw", "${c}FooBar Baz\n", "foobar Baz\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("guw", "${c}FooBar Baz\n", "foobar Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun testToggleCaseVisual() {
doTest(
"ve~", "${c}FooBar Baz\n", "fOObAR Baz\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
"ve~", "${c}FooBar Baz\n", "fOObAR Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
fun testChangeUpperCaseVisual() {
doTest(
"veU", "${c}FooBar Baz\n", "FOOBAR Baz\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
"veU", "${c}FooBar Baz\n", "FOOBAR Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
fun testChangeLowerCaseVisual() {
doTest(
"veu", "${c}FooBar Baz\n", "foobar Baz\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
"veu", "${c}FooBar Baz\n", "foobar Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -180,7 +180,7 @@ class ChangeActionTest : VimTestCase() {
four
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -198,7 +198,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
assertOffset(4)
}
@@ -217,8 +217,8 @@ class ChangeActionTest : VimTestCase() {
three
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -238,7 +238,7 @@ class ChangeActionTest : VimTestCase() {
three
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -252,7 +252,7 @@ class ChangeActionTest : VimTestCase() {
"""one
three
""",
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
assertOffset(3)
}
@@ -266,16 +266,16 @@ class ChangeActionTest : VimTestCase() {
three four
""".trimIndent(),
"one four\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
"one four\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
// VIM-1380 |d| |w| |count|
fun testDeleteTwoWordsAtLastChar() {
doTest(
"d2w", "on${c}e two three\n", "on${c}three\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
"d2w", "on${c}e two three\n", "on${c}three\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -289,8 +289,8 @@ class ChangeActionTest : VimTestCase() {
"""foo
, baz
""",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -308,8 +308,8 @@ class ChangeActionTest : VimTestCase() {
baz
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -327,7 +327,7 @@ class ChangeActionTest : VimTestCase() {
bar
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
assertOffset(1)
}
@@ -341,7 +341,7 @@ class ChangeActionTest : VimTestCase() {
two
""".trimIndent(),
"two\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"two\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -349,8 +349,8 @@ class ChangeActionTest : VimTestCase() {
fun testInsertFromRegister() {
setRegister('a', "World")
doTest(
listOf("A", ", ", "<C-R>", "a", "!"), "${c}Hello\n", "Hello, World!\n", CommandState.Mode.INSERT,
CommandState.SubMode.NONE
listOf("A", ", ", "<C-R>", "a", "!"), "${c}Hello\n", "Hello, World!\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
)
}
@@ -358,7 +358,7 @@ class ChangeActionTest : VimTestCase() {
fun testInsertNewLineAboveFirstLine() {
doTest(
listOf("O", "bar"),
"fo${c}o\n", "bar\nfoo\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"fo${c}o\n", "bar\nfoo\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -366,7 +366,7 @@ class ChangeActionTest : VimTestCase() {
fun testVisualSelectionRightMargin() {
doTest(
listOf("v", "k\$d"),
"foo\n${c}bar\n", "fooar\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"foo\n${c}bar\n", "fooar\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -388,7 +388,7 @@ class ChangeActionTest : VimTestCase() {
quux
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -409,7 +409,7 @@ class ChangeActionTest : VimTestCase() {
quux
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -424,7 +424,7 @@ quux
""" a 1 b 2 c 3
quux
""",
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -439,7 +439,7 @@ quux
""" a 1 b 2 c 3
quux
""",
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -451,7 +451,7 @@ quux
bar
""".trimIndent(),
"foo bar", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"foo bar", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -462,7 +462,7 @@ quux
foo
bar
""".trimIndent(),
"foo bar", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"foo bar", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -477,7 +477,7 @@ quux
""" a 1 b 2 c 3
quux
""",
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -492,14 +492,14 @@ quux
""" a 1 b 2 c 3
quux
""",
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
fun testDeleteCharVisualBlockOnLastCharOfLine() {
doTest(
listOf("<C-V>", "x"),
"fo${c}o\n", "fo\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"fo${c}o\n", "fo\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -509,7 +509,7 @@ quux
}
doTest(
listOf("<C-V>", "j", "x"),
"\n\n", "\n\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"\n\n", "\n\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -529,7 +529,7 @@ quux
br
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -550,7 +550,7 @@ quux
br
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -575,18 +575,18 @@ quux
// |r|
fun testReplaceOneChar() {
doTest("rx", "b${c}ar\n", "b${c}xr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("rx", "b${c}ar\n", "b${c}xr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |r|
@VimBehaviorDiffers(originalVimAfter = "foXX${c}Xr\n")
fun testReplaceMultipleCharsWithCount() {
doTest("3rX", "fo${c}obar\n", "fo${c}XXXr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("3rX", "fo${c}obar\n", "fo${c}XXXr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |r|
fun testReplaceMultipleCharsWithCountPastEndOfLine() {
doTest("6rX", "fo${c}obar\n", "fo${c}obar\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("6rX", "fo${c}obar\n", "fo${c}obar\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |r|
@@ -604,7 +604,7 @@ quux
ZZZZZz
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -619,7 +619,7 @@ foobaz
bar
foobaz
""",
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -635,20 +635,20 @@ foobaz
r
foobaz
""",
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
// |s|
fun testReplaceOneCharWithText() {
doTest("sxy<Esc>", "b${c}ar\n", "bx${c}yr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("sxy<Esc>", "b${c}ar\n", "bx${c}yr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |s|
fun testReplaceMultipleCharsWithTextWithCount() {
doTest(
"3sxy<Esc>",
"fo${c}obar\n", "fox${c}yr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"fo${c}obar\n", "fox${c}yr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -666,13 +666,13 @@ foobaz
biff
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
// |R|
fun testReplaceMode() {
doTest("Rbaz<Esc>", "foo${c}bar\n", "fooba${c}z\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("Rbaz<Esc>", "foo${c}bar\n", "fooba${c}z\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |R| |i_<Insert>|
@@ -680,7 +680,7 @@ foobaz
fun testReplaceModeSwitchToInsertModeAndBack() {
doTest(
"RXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zddd\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zddd\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -689,8 +689,8 @@ foobaz
fun testInsertModeSwitchToReplaceModeAndBack() {
doTest(
"iXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zcccddd\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zcccddd\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -709,7 +709,7 @@ foobaz
fo${c}o quux
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -917,17 +917,17 @@ and some text after"""
fun testRepeatChangeWordDoesNotBreakNextRepeatFind() {
doTest(
"fXcfYPATATA<Esc>fX.;.", "${c}aaaaXBBBBYaaaaaaaXBBBBYaaaaaaXBBBBYaaaaaaaa\n",
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
fun testRepeatReplace() {
configureByText("${c}foobarbaz spam\n")
typeText(injector.parser.parseKeys("R"))
assertMode(CommandState.Mode.REPLACE)
assertMode(VimStateMachine.Mode.REPLACE)
typeText(injector.parser.parseKeys("FOO" + "<Esc>" + "l" + "2."))
assertState("FOOFOOFO${c}O spam\n")
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
}
fun testDownMovementAfterDeletionToStart() {
@@ -941,8 +941,8 @@ and some text after"""
psum dolor sit amet
${c}lorem ipsum dolor sit amet
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -957,8 +957,8 @@ and some text after"""
ipsum dolor sit amet
${c}lorem ipsum dolor sit amet
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -973,8 +973,8 @@ and some text after"""
ipsum dolor sit amet
${c}lorem ipsum dolor sit amet
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -989,8 +989,8 @@ and some text after"""
ipsum dolor sit amet
${c}lorem ipsum dolor sit amet
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -1005,8 +1005,8 @@ and some text after"""
${c}lorem ipsum dolor sit amet
psum dolor sit amet
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -1021,8 +1021,8 @@ and some text after"""
${c}lorem ipsum dolor sit amet
ipsum dolor sit amet
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -1040,7 +1040,7 @@ and some text after"""
${c}lorem ipsum dolor sit amet
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -1059,7 +1059,7 @@ and some text after"""
gaganis ${c}gaganis gaganis
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -1075,7 +1075,7 @@ and some text after"""
line 1
${c}line 3
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -19,7 +19,7 @@
package org.jetbrains.plugins.ideavim.action;
import com.google.common.collect.Lists;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.VimStateMachine;
import org.jetbrains.plugins.ideavim.VimTestCase;
/**
@@ -27,128 +27,128 @@ import org.jetbrains.plugins.ideavim.VimTestCase;
*/
public class ChangeNumberActionTest extends VimTestCase {
public void testIncrementDecimalZero() {
doTest("<C-A>", "0", "1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "0", "1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementHexZero() {
doTest("<C-A>", "0x0", "0x1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "0x0", "0x1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testDecrementZero() {
doTest("<C-X>", "0", "-1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-X>", "0", "-1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementDecimal() {
doTest("<C-A>", "199", "200", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "199", "200", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testDecrementDecimal() {
doTest("<C-X>", "1000", "999", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-X>", "1000", "999", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementOctal() {
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0477", "0500", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0477", "0500", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testDecrementOctal() {
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "010", "007", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "010", "007", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementHex() {
doTest("<C-A>", "0xff", "0x100", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "0xff", "0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testDecrementHex() {
doTest("<C-X>", "0xa100", "0xa0ff", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-X>", "0xa100", "0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementNegativeDecimal() {
doTest("<C-A>", "-199", "-198", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "-199", "-198", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testDecrementNegativeDecimal() {
doTest("<C-X>", "-1000", "-1001", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-X>", "-1000", "-1001", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementNegativeOctal() {
// Minus isn't processed
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "-0477", "-0500", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "-0477", "-0500", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testDecrementNegativeOctal() {
// Minus isn't processed
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "-010", "-007", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "-010", "-007", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementNegativeHex() {
doTest("<C-A>", "-0xff", "-0x100", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "-0xff", "-0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testDecrementNegativeHex() {
doTest("<C-X>", "-0xa100", "-0xa0ff", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-X>", "-0xa100", "-0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementWithCount() {
doTest("123<C-A>", "456", "579", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("123<C-A>", "456", "579", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testDecrementWithCount() {
doTest("200<C-X>", "100", "-100", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("200<C-X>", "100", "-100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementAlphaWithoutNumberFormatAlpha() {
doTest("<C-A>", "foo", "foo", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "foo", "foo", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementAlphaWithNumberFormatAlpha() {
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "foo", "goo", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "foo", "goo", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementZWithNumberFormatAlpha() {
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "zzz", "zzz", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "zzz", "zzz", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementXInHexNumberWithNumberFormatAlphaButNotHex() {
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "0<caret>x1", "0y1", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "0<caret>x1", "0y1", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementXInHexNumberWithNumberFormatHexAlpha() {
doTest(Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"), "0<caret>x1", "0x2", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"), "0<caret>x1", "0x2", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementHexNumberWithoutNumberFormatHex() {
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0x42", "1x42", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0x42", "1x42", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementOctalNumberWithoutNumberFormatOctal() {
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "077", "078", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "077", "078", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementNegativeOctalNumberWithoutNumberFormatOctal() {
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "-077", "-076", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "-077", "-076", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
public void testIncrementHexPreservesCaseOfX() {
doTest("<C-A>", "0X88", "0X89", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "0X88", "0X89", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementHexTakesCaseFromLastLetter() {
doTest("<C-A>", "0xaB0", "0xAB1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
doTest("<C-A>", "0xaB0", "0xAB1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
public void testIncrementLocatesNumberOnTheSameLine() {
doTest("<C-A>", "foo ->* bar 123\n", "foo ->* bar 12<caret>4\n", CommandState.Mode.COMMAND,
CommandState.SubMode.NONE);
doTest("<C-A>", "foo ->* bar 123\n", "foo ->* bar 12<caret>4\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE);
}
}

View File

@@ -21,7 +21,7 @@ package org.jetbrains.plugins.ideavim.action;
import com.intellij.openapi.editor.Editor;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.api.VimInjectorKt;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.VimStateMachine;
import com.maddyhome.idea.vim.register.Register;
import com.maddyhome.idea.vim.ex.ExException;
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
@@ -129,7 +129,7 @@ public class CopyActionTest extends VimTestCase {
public void testStateAfterYankVisualBlock() {
typeTextInFile(VimInjectorKt.getInjector().getParser().parseKeys("<C-V>" + "jl" + "y"), "<caret>foo\n" + "bar\n");
assertOffset(0);
assertMode(CommandState.Mode.COMMAND);
assertMode(VimStateMachine.Mode.COMMAND);
assertSelection(null);
}

View File

@@ -19,7 +19,7 @@
package org.jetbrains.plugins.ideavim.action
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.helper.experimentalApi
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@@ -154,7 +154,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
""".trimIndent()
)
assertMode(CommandState.Mode.INSERT)
assertMode(VimStateMachine.Mode.INSERT)
}
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@@ -176,7 +176,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
""".trimIndent()
)
assertMode(CommandState.Mode.INSERT)
assertMode(VimStateMachine.Mode.INSERT)
}
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@@ -198,7 +198,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
""".trimIndent()
)
assertMode(CommandState.Mode.INSERT)
assertMode(VimStateMachine.Mode.INSERT)
}
/*
@@ -255,7 +255,7 @@ class GuardedBlocksTest : VimTestCase() {
$c
""".trimIndent()
)
assertMode(CommandState.Mode.INSERT)
assertMode(VimStateMachine.Mode.INSERT)
}
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@@ -274,7 +274,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
""".trimIndent()
)
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
}
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@@ -294,7 +294,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
""".trimIndent()
)
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
}
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@@ -315,7 +315,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
""".trimIndent()
)
assertMode(CommandState.Mode.INSERT)
assertMode(VimStateMachine.Mode.INSERT)
}
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
@@ -335,6 +335,6 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
""".trimIndent()
)
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
}
}

View File

@@ -20,7 +20,7 @@ package org.jetbrains.plugins.ideavim.action
import com.intellij.testFramework.PlatformTestUtil
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionScope
@@ -36,7 +36,7 @@ class MacroActionTest : VimTestCase() {
// |q|
fun testRecordMacro() {
val editor = typeTextInFile(injector.parser.parseKeys("qa" + "3l" + "q"), "on<caret>e two three\n")
val commandState = editor.vim.commandState
val commandState = editor.vim.vimStateMachine
assertFalse(commandState.isRecording)
val registerGroup = VimPlugin.getRegister()
val register = registerGroup.getRegister('a')

View File

@@ -21,7 +21,7 @@ package org.jetbrains.plugins.ideavim.action;
import com.google.common.collect.Lists;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.api.VimInjectorKt;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.command.VimStateMachine;
import com.maddyhome.idea.vim.mark.Mark;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
import org.jetbrains.plugins.ideavim.SkipNeovimReason;
@@ -148,6 +148,6 @@ public class MarkTest extends VimTestCase {
// |i| |`]|
public void testGotoLastChangePositionEnd() {
doTest(Lists.newArrayList("yiw", "P", "gg", "`]"), "one two\n" + "<caret>three\n" + "four five\n",
"one two\n" + "thre<caret>ethree\n" + "four five\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
"one two\n" + "thre<caret>ethree\n" + "four five\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
}
}

View File

@@ -19,8 +19,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.CommandState
import com.maddyhome.idea.vim.helper.vimCommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.vimStateMachine
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@@ -31,7 +31,7 @@ import org.jetbrains.plugins.ideavim.VimTestCase
class MotionActionTest : VimTestCase() {
fun testDoubleToggleVisual() {
val contents = "one tw${c}o\n"
doTest("vv", contents, contents, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("vv", contents, contents, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-198 |v_iw|
@@ -41,8 +41,8 @@ class MotionActionTest : VimTestCase() {
"viw",
fileContents,
"one ${s}two${se}\n",
CommandState.Mode.VISUAL,
CommandState.SubMode.VISUAL_CHARACTER
VimStateMachine.Mode.VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER
)
}
@@ -50,7 +50,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, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER)
doTest("viW", fileContents, fileContentsAfter, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
assertSelection("two.three")
}
@@ -60,7 +60,7 @@ class MotionActionTest : VimTestCase() {
three
""".trimIndent()
doTest(listOf("f", "<Esc>", "<Esc>"), content, content, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(listOf("f", "<Esc>", "<Esc>"), content, content, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
assertPluginError(true)
assertOffset(2)
}
@@ -71,9 +71,9 @@ class MotionActionTest : VimTestCase() {
three
""".trimIndent()
doTest(listOf("12", "<Esc>"), content, content, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(listOf("12", "<Esc>"), content, content, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
assertPluginError(false)
val vimCommandState = myFixture.editor.vimCommandState
val vimCommandState = myFixture.editor.vimStateMachine
kotlin.test.assertNotNull(vimCommandState)
assertEmpty(vimCommandState.commandBuilder.keys.toList())
}
@@ -82,7 +82,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(listOf("14l", "2h"), before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |j| |k|
@@ -101,7 +101,7 @@ class MotionActionTest : VimTestCase() {
four
""".trimIndent()
doTest(listOf("2j", "k"), before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(listOf("2j", "k"), before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
@@ -114,14 +114,14 @@ 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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(listOf("f<Tab>"), before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
fun testIllegalCharArgument() {
typeTextInFile(injector.parser.parseKeys("f<Insert>"), "on${c}e two three four five six seven\n")
assertOffset(2)
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
}
// |F| |i_CTRL-K|
@@ -129,7 +129,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-771 |t| |;|
@@ -137,7 +137,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-771 |t| |;|
@@ -145,7 +145,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-771 |t| |;|
@@ -153,7 +153,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-771 |t| |;|
@@ -161,7 +161,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-771 |t| |,|
@@ -169,7 +169,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-771 |t| |,|
@@ -177,7 +177,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-771 |t| |,|
@@ -185,7 +185,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-314 |d| |v_iB|
@@ -193,7 +193,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di{")
val before = "{foo, b${c}ar, baz}\n"
val after = "{}\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-314 |d| |v_iB|
@@ -201,7 +201,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di{")
val before = "{foo, ${c}\"bar\", baz}\n"
val after = "{}\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_aB|
@@ -209,7 +209,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-261 |c| |v_iB|
@@ -238,7 +238,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_aW|
@@ -246,7 +246,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_is|
@@ -254,7 +254,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_as|
@@ -262,7 +262,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |v_as|
@@ -280,7 +280,7 @@ class MotionActionTest : VimTestCase() {
P$c.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_ip|
@@ -302,7 +302,7 @@ class MotionActionTest : VimTestCase() {
Bye.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_ap|
@@ -323,7 +323,7 @@ class MotionActionTest : VimTestCase() {
Bye.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_a]|
@@ -336,7 +336,7 @@ class MotionActionTest : VimTestCase() {
];
"""
val after = "foo = ;\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_i]|
@@ -344,7 +344,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di]")
val before = "foo = [one, t${c}wo];\n"
val after = "foo = [];\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-1287 |d| |v_i(|
@@ -352,7 +352,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-1287 |d| |v_i{|
@@ -360,7 +360,7 @@ class MotionActionTest : VimTestCase() {
val before = "{\"{foo, ${c}bar\", baz}}"
val keys = listOf("di{")
val after = "{\"{foo, ${c}bar\", baz}}"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-1287 |d| |v_i{|
@@ -368,7 +368,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-1008 |c| |v_i{|
@@ -376,7 +376,7 @@ class MotionActionTest : VimTestCase() {
val before = "\"{do${c}esn't work}\""
val keys = listOf("ci{")
val after = "\"{$c}\""
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
// VIM-1008 |c| |v_i{|
@@ -384,7 +384,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("ci{")
val before = "'{does n${c}ot work}'"
val after = "'{$c}'"
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
// VIM-1008 |c| |v_i{|
@@ -392,7 +392,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, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
// |d| |v_i>|
@@ -400,7 +400,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |d| |v_a>|
@@ -408,7 +408,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_i"|
@@ -416,7 +416,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di\"")
val before = "foo = \"bar b${c}az\";\n"
val after = "foo = \"\";\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_a"|
@@ -425,7 +425,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da\"")
val before = "foo = \"bar b${c}az\";\n"
val after = "foo = ;\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_i"|
@@ -433,7 +433,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_i"|
@@ -441,7 +441,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_i"|
@@ -449,7 +449,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_i"|
@@ -457,35 +457,35 @@ 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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun testDeleteDoubleQuotedStringOddNumberOfQuotes() {
val keys = listOf("di\"")
val before = "abc\"def${c}\"gh\"i"
val after = "abc\"\"gh\"i"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun testDeleteDoubleQuotedStringBetweenEvenNumberOfQuotes() {
val keys = listOf("di\"")
val before = "abc\"def\"g${c}h\"ijk\"l"
val after = "abc\"def\"\"ijk\"l"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun testDeleteDoubleQuotedStringOddNumberOfQuotesOnLast() {
val keys = listOf("di\"")
val before = "abcdef\"gh\"ij${c}\"kl"
val after = "abcdef\"gh\"ij\"kl"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun testDeleteDoubleQuotedStringEvenNumberOfQuotesOnLast() {
val keys = listOf("di\"")
val before = "abc\"def\"gh\"ij${c}\"kl"
val after = "abc\"def\"gh\"\"kl"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |v_i"|
@@ -493,7 +493,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, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER)
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
}
// |c| |v_i"|
@@ -501,7 +501,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("ci\"")
val before = "foo = \"${c}\";\n"
val after = "foo = \"\";\n"
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_i'|
@@ -509,7 +509,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di'")
val before = "foo = 'bar b${c}az';\n"
val after = "foo = '';\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_i`|
@@ -517,7 +517,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("di`")
val before = "foo = `bar b${c}az`;\n"
val after = "foo = ``;\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_a'|
@@ -526,7 +526,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da'")
val before = "foo = 'bar b${c}az';\n"
val after = "foo = ;\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-132 |d| |v_a`|
@@ -535,7 +535,7 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("da`")
val before = "foo = `bar b${c}az`;\n"
val after = "foo = ;\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-1427
@@ -543,7 +543,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-2113
@@ -551,14 +551,14 @@ class MotionActionTest : VimTestCase() {
val keys = listOf("cit")
val before = "<a><c>$c</c></a>"
val after = "<a><c></c></a>"
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
fun testDeleteToDigraph() {
val keys = listOf("d/<C-K>O:<CR>")
val before = "ab${c}cdÖef"
val after = "abÖef"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |[(|
@@ -801,7 +801,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |CTRL-V|
@@ -817,7 +817,7 @@ two
${s}ba${se}r
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_BLOCK)
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
}
// |CTRL-V|
@@ -833,7 +833,7 @@ two
b${s}ar$se
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_BLOCK)
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
}
// |CTRL-V|
@@ -851,7 +851,7 @@ two
a${s}b$se
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_BLOCK)
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
}
// |v_o|
@@ -859,7 +859,7 @@ two
val keys = listOf("v", "l", "o", "l", "d")
val before = "${c}foo\n"
val after = "fo\n"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-564 |g_|
@@ -880,8 +880,8 @@ two
four
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -903,8 +903,8 @@ two
four
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -924,7 +924,7 @@ two
bar
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// |v_>| |gv|
@@ -948,7 +948,7 @@ two
""".trimIndent()
)
typeText(injector.parser.parseKeys(">"))
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
assertState(
""" foo
bar
@@ -963,7 +963,7 @@ two
"""
)
typeText(injector.parser.parseKeys(">"))
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
assertState(
""" foo
bar
@@ -992,7 +992,7 @@ two
bar
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER)
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
}
fun testVisualLineSelectDown() {
@@ -1006,7 +1006,7 @@ two
""".trimIndent()
)
assertMode(CommandState.Mode.VISUAL)
assertMode(VimStateMachine.Mode.VISUAL)
assertSelection(
"""
bar
@@ -1029,7 +1029,7 @@ two
""".trimIndent()
)
assertMode(CommandState.Mode.VISUAL)
assertMode(VimStateMachine.Mode.VISUAL)
assertSelection(
"""
bar

View File

@@ -20,8 +20,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.CommandState
import com.maddyhome.idea.vim.common.MappingMode
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.key.MappingOwner
import junit.framework.TestCase
import org.jetbrains.plugins.ideavim.SkipNeovimReason
@@ -35,7 +35,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "<C-\\><C-N>"
val before = "A Discovery"
val after = "A Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -43,7 +43,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>")
val before = "A Discovery"
val after = "A Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -51,7 +51,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -59,7 +59,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("i", "<C-\\><C-N>", "3l")
val before = "${c}A Discovery"
val after = "A D${c}iscovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -67,7 +67,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("V", "<C-\\><C-N>")
val before = "A Discovery"
val after = "A Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -75,7 +75,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("gH", "<C-\\><C-N>")
val before = "A Discovery"
val after = "A Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -83,7 +83,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-\\><C-N>")
val before = "A Discovery"
val after = "A Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -91,7 +91,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "d<Esc>dw"
val before = "A Discovery"
val after = "Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -99,7 +99,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-\\><C-N>", "dw")
val before = "A Discovery"
val after = "Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -107,7 +107,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<Esc>", "dw")
val before = "A Discovery"
val after = "Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -115,7 +115,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-[>", "dw")
val before = "A Discovery"
val after = "Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -127,7 +127,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("d", "<C-D>", "dw")
val before = "A Discovery"
val after = "Discovery"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -135,7 +135,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = listOf("c", "<C-\\><C-N>", "another")
val before = "A Discovery"
val after = "Another Discovery"
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
@@ -143,7 +143,7 @@ class ResetModeActionTest : VimTestCase() {
val keys = "dt<esc>D"
val before = "A ${c}Discovery"
val after = "A "
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@@ -43,7 +43,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test simple repeat with dollar motion`() {
@@ -64,7 +64,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test repeat to line end`() {
@@ -85,7 +85,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(description = "Different caret position")
@@ -107,7 +107,7 @@ class RepeatChangeActionTest : VimTestCase() {
whe${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXX by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test count doesn't affect repeat`() {
@@ -128,7 +128,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(SkipNeovimReason.MULTICARET)
@@ -150,7 +150,7 @@ class RepeatChangeActionTest : VimTestCase() {
where XXXXXX settled on some sodden sand
${c}XXXXXXy the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test line motion`() {
@@ -171,7 +171,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(description = "Wrong caret position")
@@ -193,7 +193,7 @@ class RepeatChangeActionTest : VimTestCase() {
where it was settled on some sodden sand
${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(description = "Wrong caret position")
@@ -215,7 +215,7 @@ class RepeatChangeActionTest : VimTestCase() {
|where it was settled on some sodden sand
|hard by the torrent of a mountain pass.
""".trimMargin()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(description = "Wrong caret position")
@@ -237,7 +237,7 @@ class RepeatChangeActionTest : VimTestCase() {
wherXXXt was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(
@@ -271,7 +271,7 @@ class RepeatChangeActionTest : VimTestCase() {
XXXXX${c}Xy the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR)
@@ -293,7 +293,7 @@ class RepeatChangeActionTest : VimTestCase() {
${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test repeat with count`() {
@@ -314,7 +314,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, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test redo register feature`() {
@@ -331,7 +331,7 @@ class RepeatChangeActionTest : VimTestCase() {
One
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
class UndoActionTest : VimTestCase() {
@@ -33,7 +33,7 @@ class UndoActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
""".trimIndent()
val after = before
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
val editor = myFixture.editor
assertFalse(editor.caretModel.primaryCaret.hasSelection())
}
@@ -49,7 +49,7 @@ class UndoActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
""".trimIndent()
val after = before
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
assertFalse(hasSelection())
}
@@ -71,29 +71,7 @@ class UndoActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
assertFalse(hasSelection())
}
fun `test cursor movements do not require additional undo`() {
val keys = listOf("a1<Esc>ea2<Esc>ea3<Esc>", "uu")
val before = """
A Discovery
${c}I found it in a legendary land
all rocks and lavender and tufted grass,
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
val after = """
A Discovery
I1 found$c it in a legendary land
all rocks and lavender and tufted grass,
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
assertFalse(hasSelection())
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
class ChangeLineActionTest : VimTestCase() {
@@ -26,14 +26,14 @@ class ChangeLineActionTest : VimTestCase() {
setupChecks {
this.neoVim.ignoredRegisters = setOf('1', '"')
}
doTest("cc", "", "", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest("cc", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
fun `test on empty file with S`() {
setupChecks {
this.neoVim.ignoredRegisters = setOf('1', '"')
}
doTest("S", "", "", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest("S", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
fun `test on last line with S`() {
@@ -47,7 +47,7 @@ class ChangeLineActionTest : VimTestCase() {
I found it in a legendary land
$c
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -64,7 +64,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -79,7 +79,7 @@ class ChangeLineActionTest : VimTestCase() {
I found it in a legendary land
$c
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -96,7 +96,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -111,7 +111,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
all rocks and lavender and tufted grass,
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -128,7 +128,7 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -145,7 +145,7 @@ class ChangeLineActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
$c
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -182,7 +182,7 @@ class ChangeLineActionTest : VimTestCase() {
that priceless mote now dimpling the convex
and limpid teardrop on a lighted slide.
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -20,18 +20,18 @@
package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
class ChangeMotionActionTest : VimTestCase() {
// VIM-515 |c| |W|
fun `test change big word with punctuation and alpha`() {
doTest("cW", "foo${c}(bar baz\n", "foo baz\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest("cW", "foo${c}(bar baz\n", "foo baz\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
// VIM-300 |c| |w|
fun testChangeWordTwoWordsWithoutWhitespace() {
doTest("cw", "${c}\$value\n", "value\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest("cw", "${c}\$value\n", "value\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
// VIM-296 |cc|
@@ -39,7 +39,7 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"cc",
"foo\n" + "${c}bar\n",
"foo\n${c}" + "\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"foo\n${c}" + "\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -57,7 +57,7 @@ class ChangeMotionActionTest : VimTestCase() {
....${c}
}
""".trimIndent().dotToSpace(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -66,7 +66,7 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"ccbaz",
"${c}foo\n" + "bar\n",
"baz\n" + "bar\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"baz\n" + "bar\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -83,7 +83,7 @@ class ChangeMotionActionTest : VimTestCase() {
${c}
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -91,23 +91,23 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"c_baz",
"${c}foo\n" + "bar\n",
"baz\n" + "bar\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"baz\n" + "bar\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
// VIM-200 |c| |w|
fun testChangeWordAtLastChar() {
doTest(
"cw", "on${c}e two three\n", "on${c} two three\n", CommandState.Mode.INSERT,
CommandState.SubMode.NONE
"cw", "on${c}e two three\n", "on${c} two three\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
)
}
// VIM-1380 |c| |w| |count|
fun testChangeTwoWordsAtLastChar() {
doTest(
"c2w", "on${c}e two three\n", "on${c} three\n", CommandState.Mode.INSERT,
CommandState.SubMode.NONE
"c2w", "on${c}e two three\n", "on${c} three\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
)
}
@@ -125,15 +125,15 @@ class ChangeMotionActionTest : VimTestCase() {
}
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
// VIM-276 |c| |T|
fun testChangeLinesTillBackwards() {
doTest(
"cT(", "if (condition) ${c}{\n" + "}\n", "if ({\n" + "}\n", CommandState.Mode.INSERT,
CommandState.SubMode.NONE
"cT(", "if (condition) ${c}{\n" + "}\n", "if ({\n" + "}\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
)
}
@@ -143,7 +143,7 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"cFc",
"if (condition) {${c}\n" + "}\n",
"if (\n" + "}\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"if (\n" + "}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -151,7 +151,7 @@ class ChangeMotionActionTest : VimTestCase() {
fun testChangeLastWordInLine() {
doTest(
"cw",
"ab.${c}cd\n", "ab.${c}\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"ab.${c}cd\n", "ab.${c}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
@@ -159,16 +159,16 @@ class ChangeMotionActionTest : VimTestCase() {
fun testChangeLastInnerWordInLine() {
doTest(
listOf("c", "iw", "baz"),
"foo bar bo${c}o\n", "foo bar baz\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
"foo bar bo${c}o\n", "foo bar baz\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
// VIM-421 |c| |w|
fun testChangeLastCharInLine() {
doTest("cw", "fo${c}o\n", "fo${c}\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest("cw", "fo${c}o\n", "fo${c}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
fun testLastSymbolInWord() {
doTest("cw", "fo${c}o", "fo${c}", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest("cw", "fo${c}o", "fo${c}", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
}

View File

@@ -21,7 +21,7 @@
package org.jetbrains.plugins.ideavim.action.change.change
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.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@@ -45,7 +45,7 @@ class ChangeVisualActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test multiple line change in text middle`() {
@@ -65,7 +65,7 @@ class ChangeVisualActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(
@@ -97,7 +97,7 @@ class ChangeVisualActionTest : VimTestCase() {
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
fun `test multiple line change till the end with two new lines`() {
@@ -123,7 +123,7 @@ class ChangeVisualActionTest : VimTestCase() {
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(description = "Wrong caret position")
@@ -145,14 +145,14 @@ class ChangeVisualActionTest : VimTestCase() {
wh|Hello
ha|Hello
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test replace first line`() {
val keys = "VcHello<esc>"
val before = "${c}A Discovery"
val after = "Hello"
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(SkipNeovimReason.MULTICARET)
@@ -161,7 +161,7 @@ class ChangeVisualActionTest : VimTestCase() {
injector.parser.parseKeys("v2lc" + "aaa" + "<ESC>"),
"abcd${c}ffffff${c}abcde${c}aaaa\n"
)
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
assertState("abcdaa${c}afffaa${c}adeaa${c}aa\n")
}
@@ -182,8 +182,8 @@ class ChangeVisualActionTest : VimTestCase() {
ba_quux_bar
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -204,8 +204,8 @@ class ChangeVisualActionTest : VimTestCase() {
ba_quux_bar
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -20,7 +20,7 @@
package org.jetbrains.plugins.ideavim.action.change.change
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.VimTestCase
@@ -43,7 +43,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
where it was settled on some sodden sand
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
fun `test last empty line`() {
@@ -66,7 +66,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
@VimBehaviorDiffers(
@@ -99,6 +99,6 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
}
}

View File

@@ -18,16 +18,16 @@
package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
class ChangeNumberDecActionTest : VimTestCase() {
fun `test decrement hex to negative value`() {
doTest("<C-X>", "0x0000", "0xffffffffffffffff", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("<C-X>", "0x0000", "0xffffffffffffffff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test decrement hex to negative value by 10`() {
doTest("10<C-X>", "0x0005", "0xfffffffffffffffb", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("10<C-X>", "0x0005", "0xfffffffffffffffb", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test decrement oct to negative value`() {
@@ -35,13 +35,13 @@ class ChangeNumberDecActionTest : VimTestCase() {
":set nrformats+=octal<CR><C-X>",
"00000",
"01777777777777777777777",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
fun `test decrement incorrect octal`() {
doTest(":set nrformats+=octal<CR><C-X>", "008", "7", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(":set nrformats+=octal<CR><C-X>", "008", "7", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test decrement oct to negative value by 10`() {
@@ -49,8 +49,8 @@ class ChangeNumberDecActionTest : VimTestCase() {
":set nrformats+=octal<CR>10<C-X>",
"00005",
"01777777777777777777773",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -18,13 +18,13 @@
package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
import org.jetbrains.plugins.ideavim.VimTestCase
class ChangeNumberIncActionTest : VimTestCase() {
@VimBehaviorDiffers(originalVimAfter = "11X0")
fun `test inc fancy number`() {
doTest("<C-A>", "1${c}0X0", "10X1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest("<C-A>", "1${c}0X0", "10X1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
/**
@@ -38,8 +38,8 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1
number 1
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -56,8 +56,8 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1
number 1
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
/**
@@ -38,8 +38,8 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 3
number 4
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -56,8 +56,8 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 5
number 7
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -19,7 +19,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@@ -33,8 +33,8 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"V<C-X>",
"${c}12345",
"${c}12344",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -43,8 +43,8 @@ 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",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -53,8 +53,8 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"v4l<C-X>",
"11111${c}33333111111",
"11111${c}33332111111",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -81,8 +81,8 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
no dec 1
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -99,8 +99,8 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
999
999
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -109,8 +109,8 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"V<C-X>",
"1 should$c not be decremented -> 2",
"${c}0 should not be decremented -> 2",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}

View File

@@ -19,7 +19,7 @@
package org.jetbrains.plugins.ideavim.action.change.change.number
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@@ -33,8 +33,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"V<C-A>",
"${c}12345",
"${c}12346",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -43,8 +43,8 @@ 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",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -53,8 +53,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"v4l<C-A>",
"11111${c}22222111111",
"11111${c}22223111111",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -81,8 +81,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
no inc 1
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -99,8 +99,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
1000
1000
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -109,8 +109,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"V<C-A>",
"1 should$c not be incremented -> 2",
"${c}2 should not be incremented -> 2",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -142,8 +142,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"v$<C-A>",
"1 <- should$c not be incremented 2",
"1 <- should$c not be incremented 3",
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -156,8 +156,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"""1 <- should$c not be incremented 3
|2 should not be incremented -> 2
""".trimMargin(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -172,8 +172,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|2 should not be incremented -> 2
|2 should not be incremented -> 2
""".trimMargin(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -190,8 +190,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|1 <- should not be incremented -> 2
|1 <- should not be incremented -> 2
""".trimMargin(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -208,8 +208,8 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|1 <- should not be incremented 3
|1 <- should not be incremented 3
""".trimMargin(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
class DeleteEndOfLineActionTest : VimTestCase() {
@@ -37,8 +37,8 @@ class DeleteEndOfLineActionTest : VimTestCase() {
I found it in a legendary land
all rocks and lavender and tufted grass,
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService
import org.jetbrains.plugins.ideavim.OptionValueType
import org.jetbrains.plugins.ideavim.SkipNeovimReason
@@ -47,8 +47,8 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjVimOptionService.ide
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -70,8 +70,8 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjVimOptionService.ide
I found it in a legendary land all rocks and lavender and tufted grass,$c where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -96,8 +96,8 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjVimOptionService.ide
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService
import org.jetbrains.plugins.ideavim.OptionValueType
import org.jetbrains.plugins.ideavim.SkipNeovimReason
@@ -48,8 +48,8 @@ class DeleteJoinVisualLinesSpacesActionTest : VimOptionTestCase(IjVimOptionServi
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -22,7 +22,7 @@ package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.VimPlugin
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.helper.VimBehaviorDiffers
import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionScope
@@ -179,7 +179,7 @@ class DeleteMotionActionTest : VimTestCase() {
I found it in a legendary land
${c}all rocks and lavender and tufted grass,
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -203,7 +203,7 @@ class DeleteMotionActionTest : VimTestCase() {
I found it in a legendary land
all rocks and lavender and tufted grass,
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -19,7 +19,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete
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.group.visual.IdeaSelectionControl
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@@ -48,7 +48,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test delete block SW direction`() {
@@ -69,7 +69,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test delete block NW direction`() {
@@ -90,7 +90,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test delete block NE direction`() {
@@ -111,7 +111,7 @@ class DeleteVisualActionTest : VimTestCase() {
wh||t was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@@ -129,7 +129,7 @@ class DeleteVisualActionTest : VimTestCase() {
""".trimIndent()
)
IdeaSelectionControl.controlNonVimSelectionChange(myFixture.editor)
waitAndAssertMode(myFixture, CommandState.Mode.VISUAL)
waitAndAssertMode(myFixture, VimStateMachine.Mode.VISUAL)
typeText(injector.parser.parseKeys("d"))
assertState(
"""
@@ -138,7 +138,7 @@ class DeleteVisualActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
""".trimIndent()
)
assertState(CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test delete with dollar motion`() {
@@ -159,6 +159,6 @@ class DeleteVisualActionTest : VimTestCase() {
wh|
ha|
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
}

View File

@@ -20,7 +20,7 @@
package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
class DeleteVisualLinesActionTest : VimTestCase() {
@@ -38,8 +38,8 @@ class DeleteVisualLinesActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -57,8 +57,8 @@ class DeleteVisualLinesActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
${c}where it was settled on some sodden sand
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -76,8 +76,8 @@ class DeleteVisualLinesActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -95,8 +95,8 @@ class DeleteVisualLinesActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
${c}where it was settled on some sodden sand
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
}
@@ -118,7 +118,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
fun `test multiple line delete till the end with a new line`() {
@@ -141,6 +141,6 @@ class DeleteVisualLinesActionTest : VimTestCase() {
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
}

View File

@@ -22,7 +22,7 @@ package org.jetbrains.plugins.ideavim.action.change.delete
import com.maddyhome.idea.vim.VimPlugin
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.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionScope
import org.jetbrains.plugins.ideavim.OptionValueType
@@ -52,7 +52,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@TestWithoutNeovim(SkipNeovimReason.OPTION)
@@ -70,7 +70,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Today it is not working
The test is like that.
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -89,7 +89,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Today it is not working
The test is like that.
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -108,7 +108,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Today it is not working
The test is like that.
""".trimIndent(),
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
)
}
@@ -130,7 +130,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -153,7 +153,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -174,7 +174,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -197,7 +197,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -218,7 +218,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -241,7 +241,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -262,7 +262,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
all rocks and lavender and tufted grass,
${c}where it was settled on some sodden sand
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -282,7 +282,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
${c}where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -302,7 +302,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
${c}where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -342,7 +342,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -363,7 +363,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -386,7 +386,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -407,7 +407,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -430,7 +430,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
${c}
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -451,7 +451,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
all rocks and lavender and tufted grass,
${c}where it was settled on some sodden sand
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -471,7 +471,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
${c}where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -491,7 +491,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
${c}where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -532,7 +532,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -554,7 +554,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -578,7 +578,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
hard by the
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -600,7 +600,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -622,7 +622,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -644,7 +644,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent()
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@VimOptionDefaultAll
@@ -687,7 +687,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Today it is not working
The test is like that.
""".trimIndent(),
CommandState.Mode.INSERT, CommandState.SubMode.NONE
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
)
}
}

View File

@@ -19,7 +19,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@@ -64,9 +64,9 @@ class InsertAfterLineEndActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
}
}

View File

@@ -18,12 +18,12 @@
package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.VimTestCase
class InsertBeforeCursorActionTest : VimTestCase() {
fun `test check caret shape`() {
doTest("i", "123", "123", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
doTest("i", "123", "123", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
assertCaretsVisualAttributes()
}
}

View File

@@ -18,7 +18,7 @@
package org.jetbrains.plugins.ideavim.action.change.insert
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.command.VimStateMachine
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.VimTestCase
@@ -44,9 +44,9 @@ class InsertBeforeFirstNonBlankActionTest : VimTestCase() {
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
CommandState.Mode.COMMAND,
CommandState.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
)
assertMode(CommandState.Mode.COMMAND)
assertMode(VimStateMachine.Mode.COMMAND)
}
}

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