mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2024-11-25 16:42:55 +01:00
Compare commits
No commits in common. "1791692d921b19f884da13f26775567fe23a13b6" and "9dbe3c3363a1bfb6874a4bec9a1ea31ae2122751" have entirely different histories.
1791692d92
...
9dbe3c3363
10
.teamcity/_Self/Constants.kt
vendored
10
.teamcity/_Self/Constants.kt
vendored
@ -13,11 +13,7 @@ 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 = "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"
|
||||
const val RELEASE = "2021.3"
|
||||
const val RELEASE_DEV = "LATEST-EAP-SNAPSHOT"
|
||||
const val RELEASE_EAP = "LATEST-EAP-SNAPSHOT"
|
||||
}
|
||||
|
56
.teamcity/patches/buildTypes/Build.kts
vendored
56
.teamcity/patches/buildTypes/Build.kts
vendored
@ -1,56 +0,0 @@
|
||||
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.schedule
|
||||
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(DslContext.settingsRoot)
|
||||
}
|
||||
|
||||
steps {
|
||||
script {
|
||||
name = "Check"
|
||||
scriptContent = """
|
||||
java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}org.jetbrains.IdeaVim-EasyMotion' [latest-IU] -team-city
|
||||
java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}io.github.mishkun.ideavimsneak' [latest-IU] -team-city
|
||||
java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}eu.theblob42.idea.whichkey' [latest-IU] -team-city
|
||||
java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}IdeaVimExtension' [latest-IU] -team-city
|
||||
# Outdated java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}github.zgqq.intellij-enhance' [latest-IU] -team-city
|
||||
java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}com.github.copilot' [latest-IU] -team-city
|
||||
java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}com.github.dankinsoid.multicursor' [latest-IU] -team-city
|
||||
java -jar verifier/verifier-cli-dev-all.jar check-plugin '${'$'}com.joshestein.ideavim-quickscope' [latest-IU] -team-city
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
||||
triggers {
|
||||
schedule {
|
||||
schedulingPolicy = daily {
|
||||
hour = 4
|
||||
}
|
||||
branchFilter = ""
|
||||
triggerBuild = always()
|
||||
withPendingChangesOnly = false
|
||||
}
|
||||
}
|
||||
|
||||
features {
|
||||
golang {
|
||||
testFormat = "json"
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
5
.teamcity/patches/buildTypes/Qodana.kts
vendored
5
.teamcity/patches/buildTypes/Qodana.kts
vendored
@ -16,12 +16,17 @@ 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
74
.teamcity/patches/projects/_Self.kts
vendored
@ -1,74 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
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")
|
||||
}))
|
||||
|
@ -1,23 +0,0 @@
|
||||
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")
|
||||
}))
|
||||
|
@ -55,8 +55,6 @@ usual beta standards.
|
||||
* [VIM-696](https://youtrack.jetbrains.com/issue/VIM-696/vim-selection-issue-after-undo) Fix selection after undo
|
||||
* [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
|
||||
@ -65,7 +63,6 @@ usual beta standards.
|
||||
* [493](https://github.com/JetBrains/ideavim/pull/493) by [Matt Ellis](https://github.com/citizenmatt): Improvements to Commentary extension
|
||||
* [494](https://github.com/JetBrains/ideavim/pull/494) by [Matt Ellis](https://github.com/citizenmatt): Cleanup pre-212 CaretVisualAttributes compatibility code
|
||||
* [504](https://github.com/JetBrains/ideavim/pull/504) by [Matt Ellis](https://github.com/citizenmatt): Minor bug fixes
|
||||
* [519](https://github.com/JetBrains/ideavim/pull/519) by [chylex](https://github.com/chylex): Fix(VIM-2227): Wrong behavior when deleting / changing surround with invalid character
|
||||
|
||||
## 1.10.0, 2022-02-17
|
||||
|
||||
|
@ -24,7 +24,7 @@ plugins {
|
||||
java
|
||||
kotlin("jvm") version "1.6.21"
|
||||
|
||||
id("org.jetbrains.intellij") version "1.7.0-SNAPSHOT"
|
||||
id("org.jetbrains.intellij") version "1.6.0"
|
||||
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")
|
||||
|
||||
api(project(":vim-engine"))
|
||||
implementation(project(":vim-engine"))
|
||||
}
|
||||
|
||||
configurations {
|
||||
@ -145,7 +145,6 @@ tasks {
|
||||
kotlinOptions {
|
||||
jvmTarget = javaVersion
|
||||
apiVersion = "1.5"
|
||||
freeCompilerArgs = listOf("-Xjvm-default=all-compatibility")
|
||||
// allWarningsAsErrors = true
|
||||
}
|
||||
}
|
||||
@ -212,25 +211,6 @@ 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
|
||||
|
21
qodana.yaml
21
qodana.yaml
@ -1,8 +1,6 @@
|
||||
version: 1.0
|
||||
profile:
|
||||
name: Qodana
|
||||
include:
|
||||
- name: CheckDependencyLicenses
|
||||
exclude:
|
||||
- name: MoveVariableDeclarationIntoWhen
|
||||
- name: PluginXmlValidity
|
||||
@ -11,15 +9,12 @@ exclude:
|
||||
- name: UnusedReturnValue
|
||||
- name: All
|
||||
paths:
|
||||
- build.gradle.kts
|
||||
- build.gradle
|
||||
- gradle/wrapper/gradle-wrapper.properties
|
||||
- src/main/resources/icons/youtrack.svg
|
||||
- src/main/java/com/maddyhome/idea/vim/helper/SearchHelper.java
|
||||
- src/main/java/com/maddyhome/idea/vim/regexp/RegExp.kt
|
||||
- src/test/java/org/jetbrains/plugins/ideavim/propertybased/samples/JavaText.kt
|
||||
- src/test/java/org/jetbrains/plugins/ideavim/propertybased/samples/LoremText.kt
|
||||
- src/test/java/org/jetbrains/plugins/ideavim/propertybased/samples/SimpleText.kt
|
||||
- src/main/java/com/maddyhome/idea/vim/vimscript/parser/generated/VimscriptListener.java
|
||||
- src/main/java/com/maddyhome/idea/vim/vimscript/parser/generated/VimscriptLexer.java
|
||||
- src/main/java/com/maddyhome/idea/vim/vimscript/parser/generated/VimscriptParser.java
|
||||
- src/main/java/com/maddyhome/idea/vim/vimscript/parser/generated/VimscriptVisitor.java
|
||||
- resources/icons/youtrack.svg
|
||||
- src/com/maddyhome/idea/vim/ex/vimscript/VimScriptCommandHandler.java
|
||||
- src/com/maddyhome/idea/vim/helper/SearchHelper.java
|
||||
- src/com/maddyhome/idea/vim/regexp/RegExp.java
|
||||
- test/org/jetbrains/plugins/ideavim/propertybased/samples/JavaText.kt
|
||||
- test/org/jetbrains/plugins/ideavim/propertybased/samples/LoremText.kt
|
||||
- test/org/jetbrains/plugins/ideavim/propertybased/samples/SimpleText.kt
|
@ -1,13 +1,3 @@
|
||||
// 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'
|
||||
|
||||
|
@ -146,7 +146,7 @@ rShift: GREATER+;
|
||||
|
||||
letCommands:
|
||||
(WS | COLON)* range? (WS | COLON)* LET WS+ expr WS*
|
||||
assignmentOperator
|
||||
assignmentOperator = (ASSIGN | PLUS_ASSIGN | MINUS_ASSIGN | STAR_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | DOT_ASSIGN)
|
||||
WS* expr WS* ((inline_comment NEW_LINE) | (NEW_LINE | BAR)+)
|
||||
#Let1Command|
|
||||
|
||||
@ -154,21 +154,6 @@ letCommands:
|
||||
#Let2Command
|
||||
;
|
||||
|
||||
assignmentOperator:
|
||||
ASSIGN | plusAssign | minusAssign | startAssign | divAssign | modAssign | dotAssign;
|
||||
plusAssign:
|
||||
PLUS ASSIGN;
|
||||
minusAssign:
|
||||
MINUS ASSIGN;
|
||||
startAssign:
|
||||
STAR ASSIGN;
|
||||
divAssign:
|
||||
DIV ASSIGN;
|
||||
modAssign:
|
||||
MOD ASSIGN;
|
||||
dotAssign:
|
||||
DOT ASSIGN;
|
||||
|
||||
shortRange:
|
||||
((QUESTION (~QUESTION)* QUESTION?) | (DIV (~DIV)* DIV?));
|
||||
range:
|
||||
@ -793,12 +778,12 @@ IS_NOT_CS: 'isnot#';
|
||||
|
||||
// Assignment operators
|
||||
ASSIGN: '=';
|
||||
//PLUS_ASSIGN: '+=';
|
||||
//MINUS_ASSIGN: '-=';
|
||||
//STAR_ASSIGN: '*=';
|
||||
//DIV_ASSIGN: '/=';
|
||||
//MOD_ASSIGN: '%=';
|
||||
//DOT_ASSIGN: '.=';
|
||||
PLUS_ASSIGN: '+=';
|
||||
MINUS_ASSIGN: '-=';
|
||||
STAR_ASSIGN: '*=';
|
||||
DIV_ASSIGN: '/=';
|
||||
MOD_ASSIGN: '%=';
|
||||
DOT_ASSIGN: '.=';
|
||||
|
||||
// Escaped chars
|
||||
ESCAPED_QUESTION: '\\?';
|
||||
|
@ -48,13 +48,13 @@ import com.maddyhome.idea.vim.group.visual.VisualMotionGroup;
|
||||
import com.maddyhome.idea.vim.helper.MacKeyRepeat;
|
||||
import com.maddyhome.idea.vim.listener.VimListenerManager;
|
||||
import com.maddyhome.idea.vim.newapi.IjVimInjector;
|
||||
import com.maddyhome.idea.vim.options.OptionService;
|
||||
import com.maddyhome.idea.vim.ui.StatusBarIconFactory;
|
||||
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
|
||||
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel;
|
||||
import com.maddyhome.idea.vim.vimscript.services.FunctionStorage;
|
||||
import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService;
|
||||
import com.maddyhome.idea.vim.vimscript.services.OptionService;
|
||||
import com.maddyhome.idea.vim.vimscript.services.VariableService;
|
||||
import com.maddyhome.idea.vim.vimscript.services.VimVariableService;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -226,8 +226,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
||||
return (PutGroup)VimInjectorKt.getInjector().getPut();
|
||||
}
|
||||
|
||||
public static @NotNull VariableService getVariableService() {
|
||||
return ApplicationManager.getApplication().getService(VariableService.class);
|
||||
public static @NotNull VimVariableService getVariableService() {
|
||||
return ApplicationManager.getApplication().getService(VimVariableService.class);
|
||||
}
|
||||
|
||||
public static @NotNull OptionService getOptionService() {
|
||||
|
@ -34,8 +34,8 @@ 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.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
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.vimStateMachine.isDotRepeatInProgress) {
|
||||
if (!editor.commandState.isDotRepeatInProgress) {
|
||||
argumentCaptured = argument
|
||||
}
|
||||
val range = getMotionRange(editor, context, argument, operatorArguments)
|
||||
|
@ -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.vimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
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.vimStateMachine
|
||||
val state = editor.commandState
|
||||
val lastCommand = VimRepeater.lastChangeCommand
|
||||
|
||||
if (lastCommand == null && Extension.lastExtensionHandler == null) return false
|
||||
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
val mode: CommandState.Mode
|
||||
get() = machine.mode.ij
|
||||
|
||||
val commandBuilder: CommandBuilder
|
||||
get() = machine.commandBuilder
|
||||
|
||||
val mappingState: MappingState
|
||||
get() = machine.mappingState
|
||||
|
||||
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
|
||||
}
|
@ -23,15 +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.api.VimCaret
|
||||
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.vimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
import com.maddyhome.idea.vim.key.MappingOwner
|
||||
import com.maddyhome.idea.vim.key.OperatorFunction
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -49,21 +48,6 @@ import javax.swing.KeyStroke
|
||||
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(
|
||||
modes: Set<MappingMode>,
|
||||
fromKeys: List<KeyStroke>,
|
||||
@ -145,7 +129,7 @@ object VimExtensionFacade {
|
||||
/** Returns a single key stroke from the user input similar to 'getchar()'. */
|
||||
@JvmStatic
|
||||
fun inputKeyStroke(editor: Editor): KeyStroke {
|
||||
if (editor.vim.vimStateMachine.isDotRepeatInProgress) {
|
||||
if (editor.vim.commandState.isDotRepeatInProgress) {
|
||||
val input = Extension.consumeKeystroke()
|
||||
return input ?: error("Not enough keystrokes saved: ${Extension.lastExtensionHandler}")
|
||||
}
|
||||
@ -153,7 +137,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.vimStateMachine.isRecording) {
|
||||
if (editor.vim.commandState.isRecording) {
|
||||
KeyHandler.getInstance().modalEntryKeys += it
|
||||
}
|
||||
}
|
||||
@ -183,24 +167,12 @@ object VimExtensionFacade {
|
||||
return reg.keys
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getRegisterForCaret(register: Char, caret: VimCaret): List<KeyStroke>? {
|
||||
val reg = caret.registerStorage.getRegister(register) ?: return null
|
||||
return reg.keys
|
||||
}
|
||||
|
||||
/** Set the current contents of the given register */
|
||||
@JvmStatic
|
||||
fun setRegister(register: Char, keys: List<KeyStroke?>?) {
|
||||
VimPlugin.getRegister().setKeys(register, keys?.filterNotNull() ?: emptyList())
|
||||
}
|
||||
|
||||
/** Set the current contents of the given register */
|
||||
@JvmStatic
|
||||
fun setRegisterForCaret(register: Char, caret: VimCaret, keys: List<KeyStroke?>?) {
|
||||
caret.registerStorage.setKeys(register, keys?.filterNotNull() ?: emptyList())
|
||||
}
|
||||
|
||||
/** Set the current contents of the given register */
|
||||
@JvmStatic
|
||||
fun setRegister(register: Char, keys: List<KeyStroke?>?, type: SelectionType) {
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
@ -25,9 +25,9 @@ import com.maddyhome.idea.vim.api.VimExtensionRegistrator
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.ex.ExException
|
||||
import com.maddyhome.idea.vim.key.MappingOwner.Plugin.Companion.remove
|
||||
import com.maddyhome.idea.vim.option.ToggleOption
|
||||
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.statistic.PluginState
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
|
||||
|
||||
|
@ -18,21 +18,24 @@
|
||||
|
||||
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.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.extension.VimExtension;
|
||||
import com.maddyhome.idea.vim.extension.ExtensionHandler;
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionHandler;
|
||||
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;
|
||||
@ -183,7 +186,7 @@ public class VimArgTextObjExtension implements VimExtension {
|
||||
/**
|
||||
* A text object for an argument to a function definition or a call.
|
||||
*/
|
||||
static class ArgumentHandler implements ExtensionHandler {
|
||||
static class ArgumentHandler implements VimExtensionHandler {
|
||||
final boolean isInner;
|
||||
|
||||
ArgumentHandler(boolean isInner) {
|
||||
@ -259,17 +262,17 @@ public class VimArgTextObjExtension implements VimExtension {
|
||||
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
|
||||
|
||||
IjVimEditor vimEditor = (IjVimEditor) editor;
|
||||
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(vimEditor);
|
||||
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
|
||||
@NotNull CommandState commandState = CommandState.getInstance(vimEditor);
|
||||
int count = Math.max(1, commandState.getCommandBuilder().getCount());
|
||||
|
||||
final ArgumentTextObjectHandler textObjectHandler = new ArgumentTextObjectHandler(isInner);
|
||||
//noinspection DuplicatedCode
|
||||
if (!vimStateMachine.isOperatorPending()) {
|
||||
if (!commandState.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 (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
|
||||
if (commandState.getMode() == CommandState.Mode.VISUAL) {
|
||||
vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
|
||||
} else {
|
||||
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
|
||||
@ -279,7 +282,7 @@ public class VimArgTextObjExtension implements VimExtension {
|
||||
|
||||
});
|
||||
} else {
|
||||
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||
commandState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||
textObjectHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags.class))));
|
||||
}
|
||||
}
|
||||
|
@ -34,14 +34,13 @@ 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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.command.TextObjectVisualType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.common.CommandAliasHandler
|
||||
import com.maddyhome.idea.vim.common.MappingMode
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.extension.ExtensionHandler
|
||||
import com.maddyhome.idea.vim.extension.VimExtension
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.addCommand
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.executeNormalWithoutMapping
|
||||
@ -49,10 +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.handler.TextObjectActionHandler
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.PsiHelper
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
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.vimStateMachine.mode
|
||||
if (mode !== VimStateMachine.Mode.VISUAL) {
|
||||
val mode = editor.commandState.mode
|
||||
if (mode !== CommandState.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 !== VimStateMachine.Mode.VISUAL) {
|
||||
if (mode !== CommandState.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, ExtensionHandler {
|
||||
private class CommentaryOperatorHandler : OperatorFunction, VimExtensionHandler {
|
||||
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(), ExtensionHandler {
|
||||
private class CommentaryTextObjectMotionHandler : TextObjectActionHandler(), VimExtensionHandler {
|
||||
override val isRepeatable = true
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
val commandState = editor.vimStateMachine
|
||||
val commandState = editor.commandState
|
||||
val count = maxOf(1, commandState.commandBuilder.count)
|
||||
|
||||
val textObjectHandler = this
|
||||
|
@ -31,11 +31,10 @@ 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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
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.executeNormalWithoutMapping
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.getRegister
|
||||
@ -43,6 +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.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: VimStateMachine.SubMode, val start: Mark, val end: Mark, val text: String) {
|
||||
class Exchange(val type: CommandState.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) : ExtensionHandler {
|
||||
private class ExchangeHandler(private val isLine: Boolean) : VimExtensionHandler {
|
||||
override val isRepeatable = true
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
@ -121,13 +121,13 @@ class VimExchangeExtension : VimExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private class ExchangeClearHandler : ExtensionHandler {
|
||||
private class ExchangeClearHandler : VimExtensionHandler {
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
clearExchange(editor.ij)
|
||||
}
|
||||
}
|
||||
|
||||
private class VExchangeHandler : ExtensionHandler {
|
||||
private class VExchangeHandler : VimExtensionHandler {
|
||||
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 VimStateMachine.SubMode.getString() = when (this) {
|
||||
VimStateMachine.SubMode.VISUAL_CHARACTER -> "v"
|
||||
VimStateMachine.SubMode.VISUAL_LINE -> "V"
|
||||
VimStateMachine.SubMode.VISUAL_BLOCK -> "\\<C-V>"
|
||||
fun CommandState.SubMode.getString() = when (this) {
|
||||
CommandState.SubMode.VISUAL_CHARACTER -> "v"
|
||||
CommandState.SubMode.VISUAL_LINE -> "V"
|
||||
CommandState.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) {
|
||||
VimStateMachine.SubMode.VISUAL_LINE -> HighlighterTargetArea.LINES_IN_RANGE
|
||||
CommandState.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 == VimStateMachine.SubMode.VISUAL_BLOCK && y.type == VimStateMachine.SubMode.VISUAL_BLOCK) {
|
||||
return if (x.type == CommandState.SubMode.VISUAL_BLOCK && y.type == CommandState.SubMode.VISUAL_BLOCK) {
|
||||
when {
|
||||
intersects(x, y) -> {
|
||||
ExchangeCompareResult.OVERLAP
|
||||
|
@ -33,21 +33,21 @@ 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.MappingMode
|
||||
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.extension.ExtensionHandler
|
||||
import com.maddyhome.idea.vim.common.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.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.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import java.util.*
|
||||
@ -94,14 +94,14 @@ class Matchit : VimExtension {
|
||||
override var motionType: MotionType = MotionType.INCLUSIVE
|
||||
}
|
||||
|
||||
private class MatchitHandler(private val reverse: Boolean) : ExtensionHandler {
|
||||
private class MatchitHandler(private val reverse: Boolean) : VimExtensionHandler {
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
val commandState = editor.vimStateMachine
|
||||
val commandState = editor.commandState
|
||||
val count = commandState.commandBuilder.count
|
||||
|
||||
// Reset the command count so it doesn't transfer onto subsequent commands.
|
||||
editor.vimStateMachine.commandBuilder.resetCount()
|
||||
editor.commandState.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.
|
||||
|
@ -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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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.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 : ExtensionHandler {
|
||||
abstract class WriteActionHandler : VimExtensionHandler {
|
||||
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, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
VimPlugin.getVisualMotion().enterVisualMode(editor, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
KeyHandler.getInstance().reset(editor)
|
||||
}
|
||||
|
||||
|
@ -44,11 +44,11 @@ import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.common.CommandAlias
|
||||
import com.maddyhome.idea.vim.common.CommandAliasHandler
|
||||
import com.maddyhome.idea.vim.key.CommandNode
|
||||
import com.maddyhome.idea.vim.key.CommandPartNode
|
||||
import com.maddyhome.idea.vim.key.Node
|
||||
import com.maddyhome.idea.vim.key.RootNode
|
||||
import com.maddyhome.idea.vim.key.addLeafs
|
||||
import com.maddyhome.idea.vim.common.CommandNode
|
||||
import com.maddyhome.idea.vim.common.CommandPartNode
|
||||
import com.maddyhome.idea.vim.common.Node
|
||||
import com.maddyhome.idea.vim.common.RootNode
|
||||
import com.maddyhome.idea.vim.common.addLeafs
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.extension.VimExtension
|
||||
import com.maddyhome.idea.vim.group.KeyGroup
|
||||
|
@ -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.command.MappingMode
|
||||
import com.maddyhome.idea.vim.extension.ExtensionHandler
|
||||
import com.maddyhome.idea.vim.common.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.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) : ExtensionHandler {
|
||||
private class ParagraphMotionHandler(private val count: Int) : VimExtensionHandler {
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
editor.ij.vimForEachCaret { caret ->
|
||||
val motion = moveCaretToNextParagraph(editor.ij, caret, count)
|
||||
|
@ -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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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,21 +63,22 @@ class ReplaceWithRegister : VimExtension {
|
||||
putKeyMappingIfMissing(MappingMode.X, injector.parser.parseKeys("gr"), owner, injector.parser.parseKeys(RWR_VISUAL), true)
|
||||
}
|
||||
|
||||
private class RwrVisual : ExtensionHandler {
|
||||
private class RwrVisual : VimExtensionHandler {
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
val caretsAndSelections = mutableMapOf<VimCaret, VimSelection>()
|
||||
val typeInEditor = SelectionType.fromSubMode(editor.subMode)
|
||||
editor.forEachCaret { caret ->
|
||||
val selectionStart = caret.selectionStart
|
||||
val selectionEnd = caret.selectionEnd
|
||||
|
||||
val visualSelection = caret to VimSelection.create(selectionStart, selectionEnd - 1, typeInEditor, editor)
|
||||
doReplace(editor.ij, caret, PutData.VisualSelection(mapOf(visualSelection), typeInEditor))
|
||||
caretsAndSelections += caret to VimSelection.create(selectionStart, selectionEnd - 1, typeInEditor, editor)
|
||||
}
|
||||
doReplace(editor.ij, PutData.VisualSelection(caretsAndSelections, typeInEditor))
|
||||
editor.exitVisualModeNative()
|
||||
}
|
||||
}
|
||||
|
||||
private class RwrMotion : ExtensionHandler {
|
||||
private class RwrMotion : VimExtensionHandler {
|
||||
override val isRepeatable: Boolean = true
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
@ -86,7 +87,7 @@ class ReplaceWithRegister : VimExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private class RwrLine : ExtensionHandler {
|
||||
private class RwrLine : VimExtensionHandler {
|
||||
override val isRepeatable: Boolean = true
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
@ -96,12 +97,12 @@ class ReplaceWithRegister : VimExtension {
|
||||
val lineStart = editor.getLineStartOffset(logicalLine)
|
||||
val lineEnd = editor.getLineEndOffset(logicalLine, true)
|
||||
|
||||
val visualSelection = caret to VimSelection.create(lineStart, lineEnd, SelectionType.LINE_WISE, editor)
|
||||
caretsAndSelections += visualSelection
|
||||
|
||||
doReplace(editor.ij, caret, PutData.VisualSelection(mapOf(visualSelection), SelectionType.LINE_WISE))
|
||||
caretsAndSelections += caret to VimSelection.create(lineStart, lineEnd, SelectionType.LINE_WISE, editor)
|
||||
}
|
||||
|
||||
val visualSelection = PutData.VisualSelection(caretsAndSelections, SelectionType.LINE_WISE)
|
||||
doReplace(editor.ij, visualSelection)
|
||||
|
||||
editor.forEachCaret { caret ->
|
||||
val vimStart = caretsAndSelections[caret]?.vimStart
|
||||
if (vimStart != null) {
|
||||
@ -125,14 +126,13 @@ class ReplaceWithRegister : VimExtension {
|
||||
),
|
||||
selectionType
|
||||
)
|
||||
// todo multicaret
|
||||
doReplace(editor, editor.vim.primaryCaret(), visualSelection)
|
||||
doReplace(editor, visualSelection)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getRange(editor: Editor): TextRange? = when (editor.vim.mode) {
|
||||
VimStateMachine.Mode.COMMAND -> VimPlugin.getMark().getChangeMarks(editor.vim)
|
||||
VimStateMachine.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
|
||||
CommandState.Mode.COMMAND -> VimPlugin.getMark().getChangeMarks(editor.vim)
|
||||
CommandState.Mode.VISUAL -> editor.caretModel.primaryCaret.run { TextRange(selectionStart, selectionEnd) }
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@ -147,9 +147,8 @@ class ReplaceWithRegister : VimExtension {
|
||||
@NonNls
|
||||
private const val RWR_VISUAL = "<Plug>ReplaceWithRegisterVisual"
|
||||
|
||||
private fun doReplace(editor: Editor, caret: VimCaret, visualSelection: PutData.VisualSelection) {
|
||||
val lastRegisterChar = injector.registerGroup.lastRegisterChar
|
||||
val savedRegister = caret.registerStorage.getRegister(lastRegisterChar) ?: return
|
||||
private fun doReplace(editor: Editor, visualSelection: PutData.VisualSelection) {
|
||||
val savedRegister = VimPlugin.getRegister().lastRegister ?: return
|
||||
|
||||
var usedType = savedRegister.type
|
||||
var usedText = savedRegister.text
|
||||
@ -174,8 +173,8 @@ class ReplaceWithRegister : VimExtension {
|
||||
VimPlugin.getPut().putText(IjVimEditor(editor), IjExecutionContext(EditorDataContext.init(editor)), putData)
|
||||
}
|
||||
|
||||
caret.registerStorage.saveRegister(savedRegister.name, savedRegister)
|
||||
caret.registerStorage.saveRegister(VimPlugin.getRegister().defaultRegister, savedRegister)
|
||||
VimPlugin.getRegister().saveRegister(savedRegister.name, savedRegister)
|
||||
VimPlugin.getRegister().saveRegister(VimPlugin.getRegister().defaultRegister, savedRegister)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,31 +22,30 @@ import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
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.executeNormalWithoutMapping
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.getRegisterForCaret
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.getRegister
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.inputKeyStroke
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.inputString
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putExtensionHandlerMapping
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissing
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setRegisterForCaret
|
||||
import com.maddyhome.idea.vim.helper.editorMode
|
||||
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.key.OperatorFunction
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
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.helpers.ClipboardOptionHelper
|
||||
import com.maddyhome.idea.vim.put.PutData
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.awt.event.KeyEvent
|
||||
import javax.swing.KeyStroke
|
||||
@ -81,7 +80,7 @@ class VimSurroundExtension : VimExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private class YSurroundHandler : ExtensionHandler {
|
||||
private class YSurroundHandler : VimExtensionHandler {
|
||||
override val isRepeatable = true
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
@ -90,7 +89,7 @@ class VimSurroundExtension : VimExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private class VSurroundHandler : ExtensionHandler {
|
||||
private class VSurroundHandler : VimExtensionHandler {
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
val selectionStart = editor.ij.caretModel.primaryCaret.selectionStart
|
||||
// NB: Operator ignores SelectionType anyway
|
||||
@ -105,7 +104,7 @@ class VimSurroundExtension : VimExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private class CSurroundHandler : ExtensionHandler {
|
||||
private class CSurroundHandler : VimExtensionHandler {
|
||||
override val isRepeatable = true
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
@ -116,70 +115,28 @@ class VimSurroundExtension : VimExtension {
|
||||
if (charTo.code == 0) return
|
||||
|
||||
val newSurround = getOrInputPair(charTo, editor.ij) ?: return
|
||||
runWriteAction { change(editor, context, charFrom, newSurround) }
|
||||
runWriteAction { change(editor.ij, charFrom, newSurround) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun change(editor: VimEditor, context: ExecutionContext, charFrom: Char, newSurround: Pair<String, String>?) {
|
||||
// Save old register values for carets
|
||||
val surroundings = editor.sortedCarets()
|
||||
.map {
|
||||
val oldValue: List<KeyStroke>? = getRegisterForCaret(REGISTER, it)
|
||||
setRegisterForCaret(REGISTER, it, null)
|
||||
SurroundingInfo(it, null, oldValue, null)
|
||||
}
|
||||
|
||||
// Delete surrounding's content
|
||||
perform("di" + pick(charFrom), editor.ij)
|
||||
|
||||
// Add info about surrounding's inner text and location
|
||||
surroundings.forEach {
|
||||
val registerValue = getRegisterForCaret(REGISTER, it.caret)
|
||||
val innerValue = if (registerValue.isNullOrEmpty()) null else registerValue
|
||||
it.innerText = innerValue
|
||||
|
||||
val lineEndOffset = injector.engineEditorHelper.getLineEndOffset(editor, it.caret.getLine().line, false)
|
||||
if (lineEndOffset == it.caret.offset.point) {
|
||||
it.isLineEnd = true
|
||||
}
|
||||
}
|
||||
|
||||
// Remove surrounding
|
||||
perform("da" + pick(charFrom), editor.ij)
|
||||
|
||||
surroundings.forEach {
|
||||
if (it.innerText == null && getRegisterForCaret(REGISTER, it.caret)?.isNotEmpty() == true) {
|
||||
it.innerText = emptyList()
|
||||
}
|
||||
|
||||
// caret should be placed at the first char of inserted text
|
||||
// the best solution would be using [ mark after the paste, but marks are not supported by multicaret
|
||||
// todo
|
||||
if (it.innerText != null) {
|
||||
it.offset = it.caret.offset.point
|
||||
}
|
||||
}
|
||||
|
||||
surroundings
|
||||
.filter { it.innerText != null } // we do nothing with carets that are not inside the surrounding
|
||||
.map { surrounding ->
|
||||
val innerValue = injector.parser.toPrintableString(surrounding.innerText!!)
|
||||
val text = newSurround?.let { it.first + innerValue + it.second } ?: innerValue
|
||||
val textData = PutData.TextData(text, SelectionType.CHARACTER_WISE, emptyList())
|
||||
val putData = PutData(textData, null, 1, insertTextBeforeCaret = !surrounding.isLineEnd, rawIndent = true, caretAfterInsertedText = false)
|
||||
|
||||
surrounding.caret to putData
|
||||
}.forEach {
|
||||
injector.put.putTextForCaret(editor, it.first, context, it.second)
|
||||
}
|
||||
|
||||
surroundings.forEach {
|
||||
it.restoreRegister()
|
||||
}
|
||||
|
||||
if (surroundings.size == 1) {
|
||||
surroundings.first().moveCaret()
|
||||
fun change(editor: Editor, charFrom: Char, newSurround: Pair<String, String>?) {
|
||||
// We take over the " register, so preserve it
|
||||
val oldValue: List<KeyStroke>? = getRegister(REGISTER)
|
||||
// Extract the inner value
|
||||
perform("di" + pick(charFrom), editor)
|
||||
val innerValue: MutableList<KeyStroke> = getRegister(REGISTER)?.toMutableList() ?: mutableListOf()
|
||||
// Delete the surrounding
|
||||
perform("da" + pick(charFrom), editor)
|
||||
// Insert the surrounding characters and paste
|
||||
if (newSurround != null) {
|
||||
innerValue.addAll(0, injector.parser.parseKeys(newSurround.first))
|
||||
innerValue.addAll(injector.parser.parseKeys(newSurround.second))
|
||||
}
|
||||
pasteSurround(innerValue, editor)
|
||||
// Restore the old value
|
||||
setRegister(REGISTER, oldValue)
|
||||
// Jump back to start
|
||||
executeNormalWithoutMapping(injector.parser.parseKeys("`["), editor)
|
||||
}
|
||||
|
||||
private fun perform(sequence: String, editor: Editor) {
|
||||
@ -187,6 +144,21 @@ class VimSurroundExtension : VimExtension {
|
||||
.use { executeNormalWithoutMapping(injector.parser.parseKeys("\"" + REGISTER + sequence), editor) }
|
||||
}
|
||||
|
||||
private fun pasteSurround(
|
||||
innerValue: List<KeyStroke?>,
|
||||
editor: Editor,
|
||||
) { // This logic is direct from vim-surround
|
||||
val offset = editor.caretModel.offset
|
||||
val lineEndOffset = EditorHelper.getLineEndForOffset(editor, offset)
|
||||
val motionEndMark = VimPlugin.getMark().getMark(editor.vim, ']')
|
||||
val motionEndOffset = if (motionEndMark != null) {
|
||||
EditorHelper.getOffset(editor, motionEndMark.logicalLine, motionEndMark.col)
|
||||
} else -1
|
||||
val pasteCommand = if (motionEndOffset == lineEndOffset && offset + 1 == lineEndOffset) "p" else "P"
|
||||
setRegister(REGISTER, innerValue)
|
||||
perform(pasteCommand, editor)
|
||||
}
|
||||
|
||||
private fun pick(charFrom: Char) = when (charFrom) {
|
||||
'a' -> '>'
|
||||
'r' -> ']'
|
||||
@ -195,19 +167,7 @@ class VimSurroundExtension : VimExtension {
|
||||
}
|
||||
}
|
||||
|
||||
private data class SurroundingInfo(val caret: VimCaret, var innerText: List<KeyStroke>?, val oldRegisterContent: List<KeyStroke>?, var offset: Int?, var isLineEnd: Boolean = false) {
|
||||
fun restoreRegister() {
|
||||
setRegisterForCaret(REGISTER, caret, oldRegisterContent)
|
||||
}
|
||||
|
||||
fun moveCaret() {
|
||||
if (innerText != null && offset != null) {
|
||||
caret.moveToOffset(offset!! + if (isLineEnd) 1 else 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DSurroundHandler : ExtensionHandler {
|
||||
private class DSurroundHandler : VimExtensionHandler {
|
||||
override val isRepeatable = true
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||
@ -215,7 +175,7 @@ class VimSurroundExtension : VimExtension {
|
||||
val charFrom = getChar(editor.ij)
|
||||
if (charFrom.code == 0) return
|
||||
|
||||
runWriteAction { CSurroundHandler.change(editor, context, charFrom, null) }
|
||||
runWriteAction { CSurroundHandler.change(editor.ij, charFrom, null) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,9 +199,9 @@ class VimSurroundExtension : VimExtension {
|
||||
return true
|
||||
}
|
||||
|
||||
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) }
|
||||
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) }
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
@ -18,22 +18,26 @@
|
||||
|
||||
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.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.extension.VimExtension;
|
||||
import com.maddyhome.idea.vim.extension.ExtensionHandler;
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionHandler;
|
||||
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;
|
||||
|
||||
@ -84,7 +88,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 ExtensionHandler {
|
||||
static class EntireHandler implements VimExtensionHandler {
|
||||
final boolean ignoreLeadingAndTrailing;
|
||||
|
||||
EntireHandler(boolean ignoreLeadingAndTrailing) {
|
||||
@ -144,17 +148,17 @@ public class VimTextObjEntireExtension implements VimExtension {
|
||||
|
||||
@Override
|
||||
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
|
||||
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(editor);
|
||||
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
|
||||
@NotNull CommandState commandState = CommandState.getInstance(editor);
|
||||
int count = Math.max(1, commandState.getCommandBuilder().getCount());
|
||||
|
||||
final EntireTextObjectHandler textObjectHandler = new EntireTextObjectHandler(ignoreLeadingAndTrailing);
|
||||
//noinspection DuplicatedCode
|
||||
if (!vimStateMachine.isOperatorPending()) {
|
||||
if (!commandState.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 (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
|
||||
if (commandState.getMode() == CommandState.Mode.VISUAL) {
|
||||
vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
|
||||
} else {
|
||||
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
|
||||
@ -164,7 +168,7 @@ public class VimTextObjEntireExtension implements VimExtension {
|
||||
|
||||
});
|
||||
} else {
|
||||
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||
commandState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||
textObjectHandler, Command.Type.MOTION,
|
||||
EnumSet.noneOf(CommandFlags.class))));
|
||||
}
|
||||
|
@ -18,20 +18,23 @@
|
||||
|
||||
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.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.extension.VimExtension;
|
||||
import com.maddyhome.idea.vim.extension.ExtensionHandler;
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionHandler;
|
||||
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;
|
||||
@ -83,7 +86,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 ExtensionHandler {
|
||||
static class IndentObject implements VimExtensionHandler {
|
||||
final boolean includeAbove;
|
||||
final boolean includeBelow;
|
||||
|
||||
@ -272,17 +275,17 @@ public class VimIndentObject implements VimExtension {
|
||||
@Override
|
||||
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
|
||||
IjVimEditor vimEditor = (IjVimEditor)editor;
|
||||
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(vimEditor);
|
||||
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
|
||||
@NotNull CommandState commandState = CommandState.getInstance(vimEditor);
|
||||
int count = Math.max(1, commandState.getCommandBuilder().getCount());
|
||||
|
||||
final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow);
|
||||
|
||||
if (!vimStateMachine.isOperatorPending()) {
|
||||
if (!commandState.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 (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
|
||||
if (commandState.getMode() == CommandState.Mode.VISUAL) {
|
||||
vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
|
||||
} else {
|
||||
InlayHelperKt.moveToInlayAwareOffset(caret, range.getStartOffset());
|
||||
@ -292,7 +295,7 @@ public class VimIndentObject implements VimExtension {
|
||||
|
||||
});
|
||||
} else {
|
||||
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||
commandState.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||
textObjectHandler, Command.Type.MOTION,
|
||||
EnumSet.noneOf(CommandFlags.class))));
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.maddyhome.idea.vim.EventFacade;
|
||||
import com.maddyhome.idea.vim.RegisterActions;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.api.*;
|
||||
import com.maddyhome.idea.vim.command.*;
|
||||
@ -106,7 +107,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
injector.getMotion().moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret));
|
||||
}
|
||||
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), VimStateMachine.Mode.INSERT);
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
|
||||
insertText(editor, caret, "\n" + IndentConfig.create(((IjVimEditor) editor).getEditor()).createIndentBySize(col));
|
||||
|
||||
if (firstLiner) {
|
||||
@ -122,10 +123,10 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
* @param col The column to indent to
|
||||
*/
|
||||
private void insertNewLineBelow(@NotNull VimEditor editor, @NotNull VimCaret caret, int col) {
|
||||
if (editor.isOneLineMode()) return;
|
||||
if (((IjVimEditor) editor).getEditor().isOneLineMode()) return;
|
||||
|
||||
caret.moveToOffset(injector.getMotion().moveCaretToLineEnd(editor, caret));
|
||||
editor.setVimChangeActionSwitchMode(VimStateMachine.Mode.INSERT);
|
||||
injector.getMotion().moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret));
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
|
||||
insertText(editor, caret, "\n" + IndentConfig.create(((IjVimEditor) editor).getEditor()).createIndentBySize(col));
|
||||
}
|
||||
|
||||
@ -164,6 +165,41 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @Nullable Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType(@NotNull VimEditor editor,
|
||||
@NotNull VimCaret caret,
|
||||
@NotNull ExecutionContext context,
|
||||
final @NotNull Argument argument,
|
||||
boolean isChange,
|
||||
@NotNull OperatorArguments operatorArguments) {
|
||||
final TextRange range =
|
||||
injector.getMotion().getMotionRange(editor, caret, context, argument, operatorArguments);
|
||||
if (range == null) return null;
|
||||
|
||||
// Delete motion commands that are not linewise become linewise if all the following are true:
|
||||
// 1) The range is across multiple lines
|
||||
// 2) There is only whitespace before the start of the range
|
||||
// 3) There is only whitespace after the end of the range
|
||||
SelectionType type;
|
||||
if (argument.getMotion().isLinewiseMotion()) {
|
||||
type = SelectionType.LINE_WISE;
|
||||
}
|
||||
else {
|
||||
type = SelectionType.CHARACTER_WISE;
|
||||
}
|
||||
final Command motion = argument.getMotion();
|
||||
if (!isChange && !motion.isLinewiseMotion()) {
|
||||
VimLogicalPosition start = editor.offsetToLogicalPosition(range.getStartOffset());
|
||||
VimLogicalPosition end = editor.offsetToLogicalPosition(range.getEndOffset());
|
||||
if (start.getLine() != end.getLine()) {
|
||||
if (!SearchHelper.anyNonWhitespace(((IjVimEditor) editor).getEditor(), range.getStartOffset(), -1) &&
|
||||
!SearchHelper.anyNonWhitespace(((IjVimEditor) editor).getEditor(), range.getEndOffset(), 1)) {
|
||||
type = SelectionType.LINE_WISE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Pair<>(range, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType2(@NotNull VimEditor editor,
|
||||
@ -200,6 +236,60 @@ 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) {
|
||||
|
||||
// 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);
|
||||
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);
|
||||
@ -213,6 +303,48 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
return com.maddyhome.idea.vim.newapi.ChangeGroupKt.deleteRange(editor, caret, range, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete count characters and then enter insert mode
|
||||
*
|
||||
* @param editor The editor to change
|
||||
* @param caret The caret to be moved
|
||||
* @param count The number of characters to change
|
||||
* @return true if able to delete count characters, false if not
|
||||
*/
|
||||
@Override
|
||||
public boolean changeCharacters(@NotNull VimEditor editor, @NotNull VimCaret caret, int count) {
|
||||
int len = EditorHelper.getLineLength(((IjVimEditor) editor).getEditor());
|
||||
int col = ((IjVimCaret) caret).getCaret().getLogicalPosition().column;
|
||||
if (col + count >= len) {
|
||||
return changeEndOfLine(editor, caret, 1);
|
||||
}
|
||||
|
||||
boolean res = deleteCharacter(editor, caret, count, true);
|
||||
if (res) {
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete from the cursor to the end of count - 1 lines down and enter insert mode
|
||||
*
|
||||
* @param editor The editor to change
|
||||
* @param caret The caret to perform action on
|
||||
* @param count The number of lines to change
|
||||
* @return true if able to delete count lines, false if not
|
||||
*/
|
||||
@Override
|
||||
public boolean changeEndOfLine(@NotNull VimEditor editor, @NotNull VimCaret caret, int count) {
|
||||
boolean res = deleteEndOfLine(editor, caret, count);
|
||||
if (res) {
|
||||
injector.getMotion().moveCaret(editor, caret, VimPlugin.getMotion().moveCaretToLineEnd(editor, caret));
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the text covered by the motion command argument and enter insert mode
|
||||
@ -236,9 +368,9 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
String id = motion.getAction().getId();
|
||||
boolean kludge = false;
|
||||
boolean bigWord = id.equals(VIM_MOTION_BIG_WORD_RIGHT);
|
||||
final CharSequence chars = editor.text();
|
||||
final int offset = caret.getOffset().getPoint();
|
||||
int fileSize = ((int)editor.fileSize());
|
||||
final CharSequence chars = ((IjVimEditor) editor).getEditor().getDocument().getCharsSequence();
|
||||
final int offset = ((IjVimCaret) caret).getCaret().getOffset();
|
||||
int fileSize = EditorHelperRt.getFileSize(((IjVimEditor) editor).getEditor());
|
||||
if (fileSize > 0 && offset < fileSize) {
|
||||
final CharacterHelper.CharacterType charType = CharacterHelper.charType(chars.charAt(offset), bigWord);
|
||||
if (charType != CharacterHelper.CharacterType.WHITESPACE) {
|
||||
@ -247,24 +379,24 @@ 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(VimStateMachine.Mode.INSERT);
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
switch (id) {
|
||||
case VIM_MOTION_WORD_RIGHT:
|
||||
kludge = true;
|
||||
motion.setAction(injector.getActionExecutor().findVimActionOrDie(VIM_MOTION_WORD_END_RIGHT));
|
||||
motion.setAction(RegisterActions.findActionOrDie(VIM_MOTION_WORD_END_RIGHT));
|
||||
|
||||
break;
|
||||
case VIM_MOTION_BIG_WORD_RIGHT:
|
||||
kludge = true;
|
||||
motion.setAction(injector.getActionExecutor().findVimActionOrDie(VIM_MOTION_BIG_WORD_END_RIGHT));
|
||||
motion.setAction(RegisterActions.findActionOrDie(VIM_MOTION_BIG_WORD_END_RIGHT));
|
||||
|
||||
break;
|
||||
case VIM_MOTION_CAMEL_RIGHT:
|
||||
kludge = true;
|
||||
motion.setAction(injector.getActionExecutor().findVimActionOrDie(VIM_MOTION_CAMEL_END_RIGHT));
|
||||
motion.setAction(RegisterActions.findActionOrDie(VIM_MOTION_CAMEL_END_RIGHT));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -273,8 +405,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
|
||||
if (kludge) {
|
||||
int cnt = operatorArguments.getCount1() * motion.getCount();
|
||||
int pos1 = injector.getSearchHelper().findNextWordEnd(chars, offset, fileSize, cnt, bigWord, false);
|
||||
int pos2 = injector.getSearchHelper().findNextWordEnd(chars, pos1, fileSize, -cnt, bigWord, false);
|
||||
int pos1 = SearchHelper.findNextWordEnd(chars, offset, fileSize, cnt, bigWord, false);
|
||||
int pos2 = SearchHelper.findNextWordEnd(chars, pos1, fileSize, -cnt, bigWord, false);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("pos=" + offset);
|
||||
logger.debug("pos1=" + pos1);
|
||||
@ -295,11 +427,11 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (injector.getOptionService().isSet(OptionScope.GLOBAL.INSTANCE, OptionConstants.experimentalapiName, OptionConstants.experimentalapiName)) {
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.GLOBAL.INSTANCE, OptionConstants.experimentalapiName, OptionConstants.experimentalapiName)) {
|
||||
Pair<TextRange, SelectionType> deleteRangeAndType =
|
||||
getDeleteRangeAndType2(editor, caret, context, argument, true, operatorArguments.withCount0(count0));
|
||||
if (deleteRangeAndType == null) return false;
|
||||
//ChangeGroupKt.changeRange(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), deleteRangeAndType.getFirst(), deleteRangeAndType.getSecond(), ((IjExecutionContext) context).getContext());
|
||||
ChangeGroupKt.changeRange(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), deleteRangeAndType.getFirst(), deleteRangeAndType.getSecond(), ((IjExecutionContext) context).getContext());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -310,6 +442,23 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts number of lines in the visual block.
|
||||
* <p>
|
||||
* The result includes empty and short lines which does not have explicit start position (caret).
|
||||
*
|
||||
* @param editor The editor the block was selected in
|
||||
* @param range The range corresponding to the selected block
|
||||
* @return total number of lines
|
||||
*/
|
||||
public static int getLinesCountInVisualBlock(@NotNull VimEditor editor, @NotNull TextRange range) {
|
||||
final int[] startOffsets = range.getStartOffsets();
|
||||
if (startOffsets.length == 0) return 0;
|
||||
final VimLogicalPosition firstStart = editor.offsetToLogicalPosition(startOffsets[0]);
|
||||
final VimLogicalPosition lastStart = editor.offsetToLogicalPosition(startOffsets[range.size() - 1]);
|
||||
return lastStart.getLine() - firstStart.getLine() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the case of count characters
|
||||
*
|
||||
@ -335,11 +484,11 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
@NotNull TextRange range,
|
||||
boolean append,
|
||||
@NotNull OperatorArguments operatorArguments) {
|
||||
final int lines = VimChangeGroupBase.Companion.getLinesCountInVisualBlock(editor, range);
|
||||
final int lines = getLinesCountInVisualBlock(editor, range);
|
||||
final VimLogicalPosition startPosition = editor.offsetToLogicalPosition(range.getStartOffset());
|
||||
|
||||
boolean visualBlockMode = operatorArguments.getMode() == VimStateMachine.Mode.VISUAL &&
|
||||
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK;
|
||||
boolean visualBlockMode = operatorArguments.getMode() == CommandState.Mode.VISUAL &&
|
||||
operatorArguments.getSubMode() == CommandState.SubMode.VISUAL_BLOCK;
|
||||
for (Caret caret : ((IjVimEditor) editor).getEditor().getCaretModel().getAllCarets()) {
|
||||
final int line = startPosition.getLine();
|
||||
int column = startPosition.getColumn();
|
||||
@ -440,24 +589,24 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
int col = 0;
|
||||
int lines = 0;
|
||||
if (type == SelectionType.BLOCK_WISE) {
|
||||
lines = VimChangeGroupBase.Companion.getLinesCountInVisualBlock(editor, range);
|
||||
lines = getLinesCountInVisualBlock(editor, range);
|
||||
col = editor.offsetToLogicalPosition(range.getStartOffset()).getColumn();
|
||||
if (caret.getVimLastColumn() == VimMotionGroupBase.LAST_COLUMN) {
|
||||
if (UserDataManager.getVimLastColumn(((IjVimCaret) caret).getCaret()) == VimMotionGroupBase.LAST_COLUMN) {
|
||||
col = VimMotionGroupBase.LAST_COLUMN;
|
||||
}
|
||||
}
|
||||
boolean after = range.getEndOffset() >= editor.fileSize();
|
||||
boolean after = range.getEndOffset() >= EditorHelperRt.getFileSize(((IjVimEditor) editor).getEditor());
|
||||
|
||||
final VimLogicalPosition lp = editor.offsetToLogicalPosition(injector.getMotion().moveCaretToLineStartSkipLeading(editor, caret));
|
||||
final VimLogicalPosition lp = editor.offsetToLogicalPosition(VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, caret));
|
||||
|
||||
boolean res = deleteRange(editor, caret, range, type, true);
|
||||
if (res) {
|
||||
if (type == SelectionType.LINE_WISE) {
|
||||
// Please don't use `getDocument().getText().isEmpty()` because it converts CharSequence into String
|
||||
if (editor.fileSize() == 0) {
|
||||
if (((IjVimEditor) editor).getEditor().getDocument().getTextLength() == 0) {
|
||||
insertBeforeCursor(editor, context);
|
||||
}
|
||||
else if (after && !EngineEditorHelperKt.endsWithNewLine(editor)) {
|
||||
else if (after && !EditorHelperRt.endsWithNewLine(((IjVimEditor) editor).getEditor())) {
|
||||
insertNewLineBelow(editor, caret, lp.getColumn());
|
||||
}
|
||||
else {
|
||||
@ -468,7 +617,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
if (type == SelectionType.BLOCK_WISE) {
|
||||
setInsertRepeat(lines, col, false);
|
||||
}
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), VimStateMachine.Mode.INSERT);
|
||||
UserDataManager.setVimChangeActionSwitchMode(((IjVimEditor) editor).getEditor(), CommandState.Mode.INSERT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -675,7 +824,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
}
|
||||
}
|
||||
if (pos > wsoff) {
|
||||
deleteText(editor, new TextRange(wsoff, pos), null, caret);
|
||||
deleteText(editor, new TextRange(wsoff, pos), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ 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.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.common.GoalCommand;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper;
|
||||
import com.maddyhome.idea.vim.helper.EditorHelperRt;
|
||||
@ -47,6 +48,7 @@ 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;
|
||||
@ -288,7 +290,7 @@ public class FileGroup extends VimFileBase {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
Document doc = editor.getDocument();
|
||||
|
||||
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() != VimStateMachine.Mode.VISUAL) {
|
||||
if (CommandState.getInstance(new IjVimEditor(editor)).getMode() != CommandState.Mode.VISUAL) {
|
||||
LogicalPosition lp = editor.getCaretModel().getLogicalPosition();
|
||||
int col = editor.getCaretModel().getOffset() - doc.getLineStartOffset(lp.line);
|
||||
int endoff = doc.getLineEndOffset(lp.line);
|
||||
|
@ -37,8 +37,9 @@ 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.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.key.Node;
|
||||
import com.maddyhome.idea.vim.common.MappingMode;
|
||||
import com.maddyhome.idea.vim.common.Node;
|
||||
import com.maddyhome.idea.vim.common.NodesKt;
|
||||
import com.maddyhome.idea.vim.ex.ExOutputModel;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import com.maddyhome.idea.vim.helper.HelperKt;
|
||||
|
@ -44,6 +44,7 @@ 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;
|
||||
@ -59,7 +60,8 @@ 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
|
||||
@ -125,8 +127,7 @@ 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");
|
||||
@ -164,7 +165,8 @@ 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()));
|
||||
@ -198,15 +200,14 @@ 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);
|
||||
@ -238,7 +239,8 @@ 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);
|
||||
@ -288,7 +290,6 @@ 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
|
||||
*/
|
||||
@ -312,7 +313,8 @@ 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
|
||||
}
|
||||
|
||||
@ -359,10 +361,7 @@ 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);
|
||||
@ -379,10 +378,7 @@ 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);
|
||||
@ -391,8 +387,7 @@ 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);
|
||||
}
|
||||
@ -409,16 +404,6 @@ 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());
|
||||
|
@ -711,7 +711,7 @@ public class MotionGroup extends VimMotionGroupBase {
|
||||
}
|
||||
|
||||
private static int getScrollJump(@NotNull Editor editor, int height) {
|
||||
final EnumSet<CommandFlags> flags = VimStateMachine.getInstance(new IjVimEditor(editor)).getExecutingCommandFlags();
|
||||
final EnumSet<CommandFlags> flags = CommandState.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 = VimStateMachine.getInstance(new IjVimEditor(editor)).getExecutingCommandFlags();
|
||||
final EnumSet<CommandFlags> flags = CommandState.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 (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
|
||||
if (CommandState.getInstance(new IjVimEditor(editor)).getMode() == CommandState.Mode.VISUAL) {
|
||||
ModeHelper.exitVisualMode(editor);
|
||||
KeyHandler.getInstance().reset(new IjVimEditor(editor));
|
||||
}
|
||||
|
@ -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.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.ex.ExException;
|
||||
import com.maddyhome.idea.vim.ex.InvalidCommandException;
|
||||
import com.maddyhome.idea.vim.helper.UiHelper;
|
||||
@ -90,7 +90,7 @@ public class ProcessGroup extends VimProcessGroupBase {
|
||||
if (editor.isOneLineMode()) return;
|
||||
|
||||
String initText = getRange(((IjVimEditor) editor).getEditor(), cmd);
|
||||
VimStateMachine.getInstance(editor).pushModes(VimStateMachine.Mode.CMD_LINE, VimStateMachine.SubMode.NONE);
|
||||
CommandState.getInstance(editor).pushModes(CommandState.Mode.CMD_LINE, CommandState.SubMode.NONE);
|
||||
ExEntryPanel panel = ExEntryPanel.getInstance();
|
||||
panel.activate(((IjVimEditor) editor).getEditor(), ((IjExecutionContext) context).getContext(), ":", initText, 1);
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class ProcessGroup extends VimProcessGroupBase {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
VimStateMachine.getInstance(editor).popModes();
|
||||
CommandState.getInstance(editor).popModes();
|
||||
KeyHandler.getInstance().reset(editor);
|
||||
return false;
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class ProcessGroup extends VimProcessGroupBase {
|
||||
panel.deactivate(true);
|
||||
boolean res = true;
|
||||
try {
|
||||
VimStateMachine.getInstance(editor).popModes();
|
||||
CommandState.getInstance(editor).popModes();
|
||||
|
||||
logger.debug("processing command");
|
||||
|
||||
@ -152,11 +152,11 @@ public class ProcessGroup extends VimProcessGroupBase {
|
||||
|
||||
// commands executed from map command / macro should not be added to history
|
||||
private boolean skipHistory(VimEditor editor) {
|
||||
return VimStateMachine.getInstance(editor).getMappingState().isExecutingMap() || injector.getMacro().isExecutingMacro();
|
||||
return CommandState.getInstance(editor).getMappingState().isExecutingMap() || injector.getMacro().isExecutingMacro();
|
||||
}
|
||||
|
||||
public void cancelExEntry(final @NotNull VimEditor editor, boolean resetCaret) {
|
||||
VimStateMachine.getInstance(editor).popModes();
|
||||
CommandState.getInstance(editor).popModes();
|
||||
KeyHandler.getInstance().reset(editor);
|
||||
ExEntryPanel panel = ExEntryPanel.getInstance();
|
||||
panel.deactivate(true, resetCaret);
|
||||
@ -165,14 +165,14 @@ public class ProcessGroup extends VimProcessGroupBase {
|
||||
@Override
|
||||
public void startFilterCommand(@NotNull VimEditor editor, ExecutionContext context, @NotNull Command cmd) {
|
||||
String initText = getRange(((IjVimEditor) editor).getEditor(), cmd) + "!";
|
||||
VimStateMachine.getInstance(editor).pushModes(VimStateMachine.Mode.CMD_LINE, VimStateMachine.SubMode.NONE);
|
||||
CommandState.getInstance(editor).pushModes(CommandState.Mode.CMD_LINE, CommandState.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 (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
|
||||
if (CommandState.getInstance(new IjVimEditor(editor)).getMode() == CommandState.Mode.VISUAL) {
|
||||
initText = "'<,'>";
|
||||
}
|
||||
else if (cmd.getRawCount() > 0) {
|
||||
|
@ -890,10 +890,6 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
@Override
|
||||
public void setLastSearchPattern(@Nullable String lastSearchPattern) {
|
||||
this.lastSearch = lastSearchPattern;
|
||||
if (showSearchHighlight) {
|
||||
resetIncsearchHighlights();
|
||||
updateSearchHighlights();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,8 +34,8 @@ 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.SelectionType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.isBlock
|
||||
import com.maddyhome.idea.vim.command.isChar
|
||||
import com.maddyhome.idea.vim.command.isLine
|
||||
@ -60,14 +60,10 @@ import java.awt.datatransfer.DataFlavor
|
||||
import kotlin.math.min
|
||||
|
||||
class PutGroup : VimPutBase() {
|
||||
override fun putTextForCaret(editor: VimEditor, caret: VimCaret, context: ExecutionContext, data: PutData, updateVisualMarks: Boolean): Boolean {
|
||||
override fun putTextForCaret(editor: VimEditor, caret: VimCaret, context: ExecutionContext, data: PutData): Boolean {
|
||||
val additionalData = collectPreModificationData(editor, data)
|
||||
data.visualSelection?.let { deleteSelectedText(editor, data) }
|
||||
val processedText = processText(editor, data) ?: return false
|
||||
putForCaret(editor, caret, data, additionalData, context, processedText)
|
||||
if (editor.primaryCaret() == caret && updateVisualMarks) {
|
||||
wrapInsertedTextWithVisualMarks(editor, data, processedText)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ -79,7 +75,7 @@ class PutGroup : VimPutBase() {
|
||||
additionalData: Map<String, Any>,
|
||||
) {
|
||||
val visualSelection = data.visualSelection
|
||||
val subMode = visualSelection?.typeInEditor?.toSubMode() ?: VimStateMachine.SubMode.NONE
|
||||
val subMode = visualSelection?.typeInEditor?.toSubMode() ?: CommandState.SubMode.NONE
|
||||
if (OptionConstants.clipboard_ideaput in (
|
||||
injector.optionService
|
||||
.getOptionValue(OptionScope.GLOBAL, OptionConstants.clipboardName) as VimString
|
||||
@ -117,14 +113,12 @@ class PutGroup : VimPutBase() {
|
||||
val startOffsets = prepareDocumentAndGetStartOffsets(editor, caret, text.typeInRegister, data, additionalData)
|
||||
|
||||
startOffsets.forEach { startOffset ->
|
||||
val subMode = data.visualSelection?.typeInEditor?.toSubMode() ?: VimStateMachine.SubMode.NONE
|
||||
val subMode = data.visualSelection?.typeInEditor?.toSubMode() ?: CommandState.SubMode.NONE
|
||||
val endOffset = putTextInternal(
|
||||
editor, caret, context, text.text, text.typeInRegister, subMode,
|
||||
startOffset, data.count, data.indent, data.caretAfterInsertedText
|
||||
)
|
||||
if (caret == editor.primaryCaret()) {
|
||||
VimPlugin.getMark().setChangeMarks(editor, TextRange(startOffset, endOffset))
|
||||
}
|
||||
moveCaretToEndPosition(
|
||||
editor,
|
||||
caret,
|
||||
@ -239,7 +233,7 @@ class PutGroup : VimPutBase() {
|
||||
vimEditor: VimEditor,
|
||||
vimContext: ExecutionContext,
|
||||
text: ProcessedTextData,
|
||||
subMode: VimStateMachine.SubMode,
|
||||
subMode: CommandState.SubMode,
|
||||
data: PutData,
|
||||
additionalData: Map<String, Any>,
|
||||
) {
|
||||
|
@ -18,16 +18,18 @@
|
||||
|
||||
package com.maddyhome.idea.vim.group.copy
|
||||
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.action.motion.updown.MotionDownLess1FirstNonSpaceAction
|
||||
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.Argument
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.MotionGroup
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.fileSize
|
||||
import com.maddyhome.idea.vim.listener.VimYankListener
|
||||
@ -44,8 +46,8 @@ class YankGroup : YankGroupBase() {
|
||||
|
||||
fun removeListener(listener: VimYankListener) = yankListeners.remove(listener)
|
||||
|
||||
private fun notifyListeners(editor: VimEditor, textRange: TextRange) = yankListeners.forEach {
|
||||
it.yankPerformed(editor.ij, textRange)
|
||||
private fun notifyListeners(editor: Editor, textRange: TextRange) = yankListeners.forEach {
|
||||
it.yankPerformed(editor, textRange)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,38 +67,32 @@ class YankGroup : YankGroupBase() {
|
||||
operatorArguments: OperatorArguments
|
||||
): Boolean {
|
||||
val motion = argument.motion
|
||||
val type = if (motion.isLinewiseMotion()) SelectionType.LINE_WISE else SelectionType.CHARACTER_WISE
|
||||
|
||||
val nativeCaretCount = editor.nativeCarets().size
|
||||
if (nativeCaretCount <= 0) return false
|
||||
val caretModel = editor.ij.caretModel
|
||||
if (caretModel.caretCount <= 0) return false
|
||||
|
||||
val carretToRange = HashMap<VimCaret, TextRange>(nativeCaretCount)
|
||||
val ranges = ArrayList<Pair<Int, Int>>(nativeCaretCount)
|
||||
val ranges = ArrayList<Pair<Int, Int>>(caretModel.caretCount)
|
||||
|
||||
// This logic is from original vim
|
||||
val startOffsets = if (argument.motion.action is MotionDownLess1FirstNonSpaceAction) null else HashMap<VimCaret, Int>(nativeCaretCount)
|
||||
val startOffsets =
|
||||
if (argument.motion.action is MotionDownLess1FirstNonSpaceAction) null else HashMap<Caret, Int>(caretModel.caretCount)
|
||||
|
||||
for (caret in editor.nativeCarets()) {
|
||||
val motionRange = injector.motion.getMotionRange(editor, caret, context, argument, operatorArguments)
|
||||
for (caret in caretModel.allCarets) {
|
||||
val motionRange = MotionGroup.getMotionRange(editor.ij, caret, context.ij, argument, operatorArguments)
|
||||
?: continue
|
||||
|
||||
assert(motionRange.size() == 1)
|
||||
ranges.add(motionRange.startOffset to motionRange.endOffset)
|
||||
startOffsets?.put(caret, motionRange.normalize().startOffset)
|
||||
carretToRange[caret] = TextRange(motionRange.startOffset, motionRange.endOffset)
|
||||
}
|
||||
|
||||
val type = if (motion.isLinewiseMotion()) SelectionType.LINE_WISE else SelectionType.CHARACTER_WISE
|
||||
val range = getTextRange(ranges, type) ?: return false
|
||||
|
||||
if (range.size() == 0) return false
|
||||
|
||||
return yankRange(
|
||||
editor,
|
||||
carretToRange,
|
||||
range,
|
||||
type,
|
||||
startOffsets
|
||||
)
|
||||
val selectionType = if (type == SelectionType.CHARACTER_WISE && range.isMultiple) SelectionType.BLOCK_WISE else type
|
||||
return yankRange(editor.ij, range, selectionType, startOffsets)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,21 +103,19 @@ class YankGroup : YankGroupBase() {
|
||||
* @return true if able to yank the lines, false if not
|
||||
*/
|
||||
override fun yankLine(editor: VimEditor, count: Int): Boolean {
|
||||
val caretCount = editor.nativeCarets().size
|
||||
val ranges = ArrayList<Pair<Int, Int>>(caretCount)
|
||||
val caretToRange = HashMap<VimCaret, TextRange>(caretCount)
|
||||
for (caret in editor.nativeCarets()) {
|
||||
val start = injector.motion.moveCaretToLineStart(editor, caret)
|
||||
val end = min(injector.motion.moveCaretToLineEndOffset(editor, caret, count - 1, true) + 1, editor.fileSize().toInt())
|
||||
val caretModel = editor.ij.caretModel
|
||||
val ranges = ArrayList<Pair<Int, Int>>(caretModel.caretCount)
|
||||
for (caret in caretModel.allCarets) {
|
||||
val start = VimPlugin.getMotion().moveCaretToLineStart(editor, caret.vim)
|
||||
val end = min(VimPlugin.getMotion().moveCaretToLineEndOffset(editor, caret.vim, count - 1, true) + 1, editor.fileSize().toInt())
|
||||
|
||||
if (end == -1) continue
|
||||
|
||||
ranges.add(start to end)
|
||||
caretToRange[caret] = TextRange(start, end)
|
||||
}
|
||||
|
||||
val range = getTextRange(ranges, SelectionType.LINE_WISE) ?: return false
|
||||
return yankRange(editor, caretToRange, range, SelectionType.LINE_WISE, null)
|
||||
return yankRange(editor.ij, range, SelectionType.LINE_WISE, null)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +129,6 @@ class YankGroup : YankGroupBase() {
|
||||
override fun yankRange(editor: VimEditor, range: TextRange?, type: SelectionType, moveCursor: Boolean): Boolean {
|
||||
range ?: return false
|
||||
|
||||
val caretToRange = HashMap<VimCaret, TextRange>()
|
||||
val selectionType = if (type == SelectionType.CHARACTER_WISE && range.isMultiple) SelectionType.BLOCK_WISE else type
|
||||
|
||||
if (type == SelectionType.LINE_WISE) {
|
||||
@ -150,25 +143,24 @@ class YankGroup : YankGroupBase() {
|
||||
}
|
||||
}
|
||||
|
||||
val caretModel = editor.ij.caretModel
|
||||
val rangeStartOffsets = range.startOffsets
|
||||
val rangeEndOffsets = range.endOffsets
|
||||
|
||||
val startOffsets = HashMap<VimCaret, Int>(editor.nativeCarets().size)
|
||||
return if (moveCursor) {
|
||||
val startOffsets = HashMap<Caret, Int>(caretModel.caretCount)
|
||||
if (type == SelectionType.BLOCK_WISE) {
|
||||
startOffsets[editor.primaryCaret()] = range.normalize().startOffset
|
||||
caretToRange[editor.primaryCaret()] = range
|
||||
startOffsets[caretModel.primaryCaret] = range.normalize().startOffset
|
||||
} else {
|
||||
for ((i, caret) in editor.nativeCarets().withIndex()) {
|
||||
val textRange = TextRange(rangeStartOffsets[i], rangeEndOffsets[i])
|
||||
startOffsets[caret] = textRange.normalize().startOffset
|
||||
caretToRange[caret] = textRange
|
||||
val carets = caretModel.allCarets
|
||||
for (i in carets.indices) {
|
||||
startOffsets[carets[i]] = TextRange(rangeStartOffsets[i], rangeEndOffsets[i]).normalize().startOffset
|
||||
}
|
||||
}
|
||||
|
||||
return if (moveCursor) {
|
||||
yankRange(editor, caretToRange, range, selectionType, startOffsets)
|
||||
yankRange(editor.ij, range, selectionType, startOffsets)
|
||||
} else {
|
||||
yankRange(editor, caretToRange, range, selectionType, null)
|
||||
yankRange(editor.ij, range, selectionType, null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,20 +192,15 @@ class YankGroup : YankGroupBase() {
|
||||
}
|
||||
|
||||
private fun yankRange(
|
||||
editor: VimEditor,
|
||||
caretToRange: Map<VimCaret, TextRange>,
|
||||
editor: Editor,
|
||||
range: TextRange,
|
||||
type: SelectionType,
|
||||
startOffsets: Map<VimCaret, Int>?,
|
||||
startOffsets: Map<Caret, Int>?,
|
||||
): Boolean {
|
||||
startOffsets?.forEach { (caret, offset) -> injector.motion.moveCaret(editor, caret, offset) }
|
||||
startOffsets?.forEach { (caret, offset) -> MotionGroup.moveCaret(editor, caret, offset) }
|
||||
|
||||
notifyListeners(editor, range)
|
||||
|
||||
var result = true
|
||||
for ((caret, range) in caretToRange) {
|
||||
result = caret.registerStorage.storeText(editor, range, type, false) && result
|
||||
}
|
||||
return result
|
||||
return VimPlugin.getRegister().storeText(editor.vim, range, type, false)
|
||||
}
|
||||
}
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.helper.EditorDataContext
|
||||
import com.maddyhome.idea.vim.helper.editorMode
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
import com.maddyhome.idea.vim.helper.exitSelectMode
|
||||
import com.maddyhome.idea.vim.helper.exitVisualMode
|
||||
import com.maddyhome.idea.vim.helper.hasVisualSelection
|
||||
@ -35,8 +35,8 @@ import com.maddyhome.idea.vim.helper.inSelectMode
|
||||
import com.maddyhome.idea.vim.helper.inVisualMode
|
||||
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
|
||||
import com.maddyhome.idea.vim.helper.isTemplateActive
|
||||
import com.maddyhome.idea.vim.helper.mode
|
||||
import com.maddyhome.idea.vim.helper.popAllModes
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import com.maddyhome.idea.vim.listener.VimListenerManager
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -58,7 +58,7 @@ object IdeaSelectionControl {
|
||||
editor: Editor,
|
||||
selectionSource: VimListenerManager.SelectionSource = VimListenerManager.SelectionSource.OTHER,
|
||||
) {
|
||||
VimVisualTimer.singleTask(editor.editorMode) { initialMode ->
|
||||
VimVisualTimer.singleTask(editor.mode) { 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.vimStateMachine.toSimpleString()}")
|
||||
logger.debug("Some carets have selection. State before adjustment: ${editor.vim.commandState.toSimpleString()}")
|
||||
|
||||
editor.popAllModes()
|
||||
|
||||
activateMode(editor, chooseSelectionMode(editor, selectionSource, true))
|
||||
} else {
|
||||
logger.debug("None of carets have selection. State before adjustment: ${editor.vim.vimStateMachine.toSimpleString()}")
|
||||
logger.debug("None of carets have selection. State before adjustment: ${editor.vim.commandState.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.editorMode} is enabled")
|
||||
logger.debug("${editor.mode} 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): VimStateMachine.Mode {
|
||||
fun predictMode(editor: Editor, selectionSource: VimListenerManager.SelectionSource): CommandState.Mode {
|
||||
if (editor.selectionModel.hasSelection(true)) {
|
||||
if (dontChangeMode(editor)) return editor.editorMode
|
||||
if (dontChangeMode(editor)) return editor.mode
|
||||
return chooseSelectionMode(editor, selectionSource, false)
|
||||
} else {
|
||||
return chooseNonSelectionMode(editor)
|
||||
}
|
||||
}
|
||||
|
||||
private fun activateMode(editor: Editor, mode: VimStateMachine.Mode) {
|
||||
private fun activateMode(editor: Editor, mode: CommandState.Mode) {
|
||||
when (mode) {
|
||||
VimStateMachine.Mode.VISUAL -> VimPlugin.getVisualMotion()
|
||||
CommandState.Mode.VISUAL -> VimPlugin.getVisualMotion()
|
||||
.enterVisualMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
|
||||
VimStateMachine.Mode.SELECT -> VimPlugin.getVisualMotion()
|
||||
CommandState.Mode.SELECT -> VimPlugin.getVisualMotion()
|
||||
.enterSelectMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
|
||||
VimStateMachine.Mode.INSERT -> VimPlugin.getChange().insertBeforeCursor(
|
||||
CommandState.Mode.INSERT -> VimPlugin.getChange().insertBeforeCursor(
|
||||
editor.vim,
|
||||
EditorDataContext.init(editor).vim
|
||||
)
|
||||
VimStateMachine.Mode.COMMAND -> Unit
|
||||
CommandState.Mode.COMMAND -> Unit
|
||||
else -> error("Unexpected mode: $mode")
|
||||
}
|
||||
}
|
||||
|
||||
private fun dontChangeMode(editor: Editor): Boolean =
|
||||
editor.isTemplateActive() && (IdeaRefactorModeHelper.keepMode() || editor.editorMode.hasVisualSelection)
|
||||
editor.isTemplateActive() && (IdeaRefactorModeHelper.keepMode() || editor.mode.hasVisualSelection)
|
||||
|
||||
private fun chooseNonSelectionMode(editor: Editor): VimStateMachine.Mode {
|
||||
private fun chooseNonSelectionMode(editor: Editor): CommandState.Mode {
|
||||
val templateActive = editor.isTemplateActive()
|
||||
if (templateActive && editor.inNormalMode || editor.inInsertMode) {
|
||||
return VimStateMachine.Mode.INSERT
|
||||
return CommandState.Mode.INSERT
|
||||
}
|
||||
return VimStateMachine.Mode.COMMAND
|
||||
return CommandState.Mode.COMMAND
|
||||
}
|
||||
|
||||
private fun chooseSelectionMode(
|
||||
editor: Editor,
|
||||
selectionSource: VimListenerManager.SelectionSource,
|
||||
logReason: Boolean,
|
||||
): VimStateMachine.Mode {
|
||||
): CommandState.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")
|
||||
VimStateMachine.Mode.SELECT
|
||||
CommandState.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")
|
||||
VimStateMachine.Mode.SELECT
|
||||
CommandState.Mode.SELECT
|
||||
}
|
||||
editor.isTemplateActive() && IdeaRefactorModeHelper.selectMode() -> {
|
||||
if (logReason) logger.debug("Enter select mode. Template is active and selectMode has template")
|
||||
VimStateMachine.Mode.SELECT
|
||||
CommandState.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")
|
||||
VimStateMachine.Mode.SELECT
|
||||
CommandState.Mode.SELECT
|
||||
}
|
||||
else -> {
|
||||
if (logReason) logger.debug("Enter visual mode")
|
||||
VimStateMachine.Mode.VISUAL
|
||||
CommandState.Mode.VISUAL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
package com.maddyhome.idea.vim.group.visual
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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: VimStateMachine.Mode? = null
|
||||
var mode: CommandState.Mode? = null
|
||||
|
||||
inline fun singleTask(currentMode: VimStateMachine.Mode, crossinline task: (initialMode: VimStateMachine.Mode?) -> Unit) {
|
||||
inline fun singleTask(currentMode: CommandState.Mode, crossinline task: (initialMode: CommandState.Mode?) -> Unit) {
|
||||
swingTimer?.stop()
|
||||
|
||||
if (mode == null) mode = currentMode
|
||||
@ -92,7 +92,7 @@ object VimVisualTimer {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun timerAction(task: (initialMode: VimStateMachine.Mode?) -> Unit) {
|
||||
inline fun timerAction(task: (initialMode: CommandState.Mode?) -> Unit) {
|
||||
task(mode)
|
||||
swingTimer = null
|
||||
mode = null
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.editorMode
|
||||
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.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 == VimStateMachine.SubMode.VISUAL_LINE) {
|
||||
return if (editor.subMode == CommandState.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: VimStateMachine.Mode) {
|
||||
if (predictedMode != VimStateMachine.Mode.VISUAL) {
|
||||
fun moveCaretOneCharLeftFromSelectionEnd(editor: Editor, predictedMode: CommandState.Mode) {
|
||||
if (predictedMode != CommandState.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.editorMode
|
||||
val mode = editor.mode
|
||||
val vimEditor = IjVimEditor(editor)
|
||||
when (subMode) {
|
||||
VimStateMachine.SubMode.VISUAL_CHARACTER -> {
|
||||
CommandState.SubMode.VISUAL_CHARACTER -> {
|
||||
val (nativeStart, nativeEnd) = charToNativeSelection(vimEditor, start, end, mode)
|
||||
caret.vimSetSystemSelectionSilently(nativeStart, nativeEnd)
|
||||
}
|
||||
VimStateMachine.SubMode.VISUAL_LINE -> {
|
||||
CommandState.SubMode.VISUAL_LINE -> {
|
||||
val (nativeStart, nativeEnd) = lineToNativeSelection(vimEditor, start, end)
|
||||
caret.vimSetSystemSelectionSilently(nativeStart, nativeEnd)
|
||||
}
|
||||
VimStateMachine.SubMode.VISUAL_BLOCK -> {
|
||||
CommandState.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 != VimStateMachine.Mode.SELECT &&
|
||||
if (mode != CommandState.Mode.SELECT &&
|
||||
!EditorHelper.isLineEmpty(editor, line, false) &&
|
||||
aCaret.offset == aCaret.selectionEnd &&
|
||||
aCaret.selectionEnd - 1 >= lineStartOffset &&
|
||||
|
@ -19,33 +19,22 @@
|
||||
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): VimStateMachine.SubMode {
|
||||
override fun autodetectVisualSubmode(editor: VimEditor): CommandState.SubMode {
|
||||
// IJ specific. See https://youtrack.jetbrains.com/issue/VIM-1924.
|
||||
val project = editor.ij.project
|
||||
if (project != null && FindManager.getInstance(project).selectNextOccurrenceWasPerformed()) {
|
||||
return VimStateMachine.SubMode.VISUAL_CHARACTER
|
||||
return CommandState.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)
|
||||
}
|
||||
}
|
||||
|
@ -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.command.MappingMode
|
||||
import com.maddyhome.idea.vim.common.MappingMode
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
/**
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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.vimStateMachine.isReplaceCharacter) {
|
||||
if (this.vim.commandState.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 (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
|
||||
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
|
||||
// This doesn't handle ci and cr, but we don't care - our CMD_LINE will never call this
|
||||
VimStateMachine.Mode.CMD_LINE -> GuiCursorMode.CMD_LINE
|
||||
VimStateMachine.Mode.INSERT_NORMAL -> GuiCursorMode.NORMAL
|
||||
VimStateMachine.Mode.INSERT_VISUAL -> GuiCursorMode.VISUAL
|
||||
VimStateMachine.Mode.INSERT_SELECT -> GuiCursorMode.INSERT
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class CommandLineHelper : VimCommandLineHelper {
|
||||
|
||||
override fun inputString(vimEditor: VimEditor, prompt: String, finishOn: Char?): String? {
|
||||
val editor = vimEditor.ij
|
||||
if (vimEditor.vimStateMachine.isDotRepeatInProgress) {
|
||||
if (vimEditor.commandState.isDotRepeatInProgress) {
|
||||
val input = Extension.consumeString()
|
||||
return input ?: error("Not enough strings saved: ${Extension.lastExtensionHandler}")
|
||||
}
|
||||
|
@ -23,104 +23,89 @@ 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.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 -> {
|
||||
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 -> {
|
||||
// One day we'll use a proper insert_normal mode
|
||||
if (this.editorMode.inSingleMode) true else usesVirtualSpace
|
||||
if (this.mode.inSingleMode) true else usesVirtualSpace
|
||||
}
|
||||
}
|
||||
|
||||
val VimStateMachine.Mode.isEndAllowedIgnoringOnemore: Boolean
|
||||
val CommandState.Mode.isEndAllowedIgnoringOnemore: Boolean
|
||||
get() = when (this) {
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
val VimStateMachine.Mode.hasVisualSelection
|
||||
val CommandState.Mode.hasVisualSelection
|
||||
get() = when (this) {
|
||||
VimStateMachine.Mode.VISUAL, VimStateMachine.Mode.SELECT -> true
|
||||
VimStateMachine.Mode.REPLACE, VimStateMachine.Mode.CMD_LINE, VimStateMachine.Mode.COMMAND, VimStateMachine.Mode.INSERT, VimStateMachine.Mode.OP_PENDING -> false
|
||||
VimStateMachine.Mode.INSERT_NORMAL -> false
|
||||
VimStateMachine.Mode.INSERT_VISUAL -> true
|
||||
VimStateMachine.Mode.INSERT_SELECT -> true
|
||||
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
|
||||
}
|
||||
|
||||
val Editor.editorMode
|
||||
get() = this.vim.vimStateMachine.mode
|
||||
|
||||
/**
|
||||
* COMPATIBILITY-LAYER: New method
|
||||
*/
|
||||
val Editor.mode
|
||||
get() = this.vim.vimStateMachine.mode.ij
|
||||
|
||||
/**
|
||||
* COMPATIBILITY-LAYER: New method
|
||||
*/
|
||||
val CommandState.Mode.isEndAllowed: Boolean
|
||||
get() = this.engine.isEndAllowed
|
||||
get() = this.vim.commandState.mode
|
||||
|
||||
var Editor.subMode
|
||||
get() = this.vim.vimStateMachine.subMode
|
||||
get() = this.vim.commandState.subMode
|
||||
set(value) {
|
||||
this.vim.vimStateMachine.subMode = value
|
||||
this.vim.commandState.subMode = value
|
||||
}
|
||||
|
||||
@get:JvmName("inNormalMode")
|
||||
val Editor.inNormalMode
|
||||
get() = this.editorMode.inNormalMode
|
||||
get() = this.mode.inNormalMode
|
||||
|
||||
@get:JvmName("inNormalMode")
|
||||
val VimStateMachine.Mode.inNormalMode
|
||||
get() = this == VimStateMachine.Mode.COMMAND || this == VimStateMachine.Mode.INSERT_NORMAL
|
||||
val CommandState.Mode.inNormalMode
|
||||
get() = this == CommandState.Mode.COMMAND || this == CommandState.Mode.INSERT_NORMAL
|
||||
|
||||
@get:JvmName("inInsertMode")
|
||||
val Editor.inInsertMode
|
||||
get() = this.editorMode == VimStateMachine.Mode.INSERT || this.editorMode == VimStateMachine.Mode.REPLACE
|
||||
get() = this.mode == CommandState.Mode.INSERT || this.mode == CommandState.Mode.REPLACE
|
||||
|
||||
@get:JvmName("inRepeatMode")
|
||||
val Editor.inRepeatMode
|
||||
get() = this.vim.vimStateMachine.isDotRepeatInProgress
|
||||
get() = this.vim.commandState.isDotRepeatInProgress
|
||||
|
||||
@get:JvmName("inVisualMode")
|
||||
val Editor.inVisualMode
|
||||
get() = this.editorMode.inVisualMode
|
||||
get() = this.mode.inVisualMode
|
||||
|
||||
@get:JvmName("inSelectMode")
|
||||
val Editor.inSelectMode
|
||||
get() = this.editorMode == VimStateMachine.Mode.SELECT || this.editorMode == VimStateMachine.Mode.INSERT_SELECT
|
||||
get() = this.mode == CommandState.Mode.SELECT || this.mode == CommandState.Mode.INSERT_SELECT
|
||||
|
||||
val VimEditor.inSelectMode
|
||||
get() = this.mode == VimStateMachine.Mode.SELECT || this.mode == VimStateMachine.Mode.INSERT_SELECT
|
||||
get() = this.mode == CommandState.Mode.SELECT || this.mode == CommandState.Mode.INSERT_SELECT
|
||||
|
||||
@get:JvmName("inBlockSubMode")
|
||||
val Editor.inBlockSubMode
|
||||
get() = this.subMode == VimStateMachine.SubMode.VISUAL_BLOCK
|
||||
get() = this.subMode == CommandState.SubMode.VISUAL_BLOCK
|
||||
|
||||
@get:JvmName("inSingleCommandMode")
|
||||
val Editor.inSingleCommandMode: Boolean
|
||||
get() = this.editorMode.inSingleMode
|
||||
get() = this.mode.inSingleMode
|
||||
|
||||
@get:JvmName("inSingleMode")
|
||||
val VimStateMachine.Mode.inSingleMode: Boolean
|
||||
val CommandState.Mode.inSingleMode: Boolean
|
||||
get() = when (this) {
|
||||
VimStateMachine.Mode.INSERT_NORMAL, VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.Mode.INSERT_VISUAL -> true
|
||||
CommandState.Mode.INSERT_NORMAL, CommandState.Mode.INSERT_SELECT, CommandState.Mode.INSERT_VISUAL -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
@get:JvmName("inSingleNormalMode")
|
||||
val VimStateMachine.Mode.inSingleNormalMode: Boolean
|
||||
val CommandState.Mode.inSingleNormalMode: Boolean
|
||||
get() = when (this) {
|
||||
VimStateMachine.Mode.INSERT_NORMAL -> true
|
||||
CommandState.Mode.INSERT_NORMAL -> true
|
||||
else -> false
|
||||
}
|
||||
|
@ -152,13 +152,6 @@ 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
|
||||
*
|
||||
@ -860,7 +853,7 @@ public class EditorHelper {
|
||||
if (inlayAwareOffset == vimLastColumn) return vimLastColumn;
|
||||
|
||||
Editor editor = caret.getEditor();
|
||||
boolean isEndAllowed = CommandStateHelper.isEndAllowedIgnoringOnemore(CommandStateHelper.getEditorMode(editor));
|
||||
boolean isEndAllowed = CommandStateHelper.isEndAllowedIgnoringOnemore(CommandStateHelper.getMode(editor));
|
||||
final LogicalPosition logicalPosition = caret.getLogicalPosition();
|
||||
int lastColumn = EditorHelper.lastColumnForLine(editor, logicalPosition.line, isEndAllowed);
|
||||
|
||||
|
@ -21,24 +21,18 @@ package com.maddyhome.idea.vim.helper
|
||||
import com.intellij.openapi.actionSystem.ActionGroup
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.AnActionResult
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys
|
||||
import com.intellij.openapi.actionSystem.Presentation
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil
|
||||
import com.intellij.openapi.command.CommandProcessor
|
||||
import com.intellij.openapi.command.UndoConfirmationPolicy
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.editor.actionSystem.DocCommandGroupId
|
||||
import com.intellij.openapi.project.IndexNotReadyException
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.util.SlowOperations
|
||||
import com.maddyhome.idea.vim.RegisterActions
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.NativeAction
|
||||
@ -101,48 +95,11 @@ class IjActionExecutor : VimActionExecutor {
|
||||
popup.showInFocusCenter()
|
||||
return true
|
||||
} else {
|
||||
performDumbAwareWithCallbacks(ijAction, event) { ijAction.actionPerformed(event) }
|
||||
ActionUtil.performActionDumbAwareWithCallbacks(ijAction, event)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// This is taken directly from ActionUtil.performActionDumbAwareWithCallbacks
|
||||
// But with one check removed. With this check some actions (like `:w` doesn't work)
|
||||
// https://youtrack.jetbrains.com/issue/VIM-2691/File-is-not-saved-on-w
|
||||
private fun performDumbAwareWithCallbacks(
|
||||
action: AnAction,
|
||||
event: AnActionEvent,
|
||||
performRunnable: Runnable,
|
||||
) {
|
||||
val project = event.project
|
||||
var indexError: IndexNotReadyException? = null
|
||||
val manager = ActionManagerEx.getInstanceEx()
|
||||
manager.fireBeforeActionPerformed(action, event)
|
||||
val component = event.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT)
|
||||
var result: AnActionResult? = null
|
||||
try {
|
||||
SlowOperations.allowSlowOperations(SlowOperations.ACTION_PERFORM).use { ignore ->
|
||||
performRunnable.run()
|
||||
result = AnActionResult.PERFORMED
|
||||
}
|
||||
} catch (ex: IndexNotReadyException) {
|
||||
indexError = ex
|
||||
result = AnActionResult.failed(ex)
|
||||
} catch (ex: RuntimeException) {
|
||||
result = AnActionResult.failed(ex)
|
||||
throw ex
|
||||
} catch (ex: Error) {
|
||||
result = AnActionResult.failed(ex)
|
||||
throw ex
|
||||
} finally {
|
||||
if (result == null) result = AnActionResult.failed(Throwable())
|
||||
manager.fireAfterActionPerformed(action, event, result!!)
|
||||
}
|
||||
if (indexError != null) {
|
||||
ActionUtil.showDumbModeWarning(project, event)
|
||||
}
|
||||
}
|
||||
|
||||
private fun canBePerformed(event: AnActionEvent, action: ActionGroup, context: DataContext): Boolean {
|
||||
val presentation = event.presentation
|
||||
return try {
|
||||
@ -198,10 +155,6 @@ class IjActionExecutor : VimActionExecutor {
|
||||
return RegisterActions.findAction(id)
|
||||
}
|
||||
|
||||
override fun findVimActionOrDie(id: String): EditorActionHandlerBase {
|
||||
return RegisterActions.findActionOrDie(id)
|
||||
}
|
||||
|
||||
override fun getAction(actionId: String): NativeAction? {
|
||||
return ActionManager.getInstance().getAction(actionId)?.let { IjNativeAction(it) }
|
||||
}
|
||||
|
@ -143,8 +143,4 @@ class IjEditorHelper : EngineEditorHelper {
|
||||
override fun getLeadingWhitespace(editor: VimEditor, line: Int): String {
|
||||
return EditorHelper.getLeadingWhitespace(editor.ij, line)
|
||||
}
|
||||
|
||||
override fun anyNonWhitespace(editor: VimEditor, offset: Int, dir: Int): Boolean {
|
||||
return SearchHelper.anyNonWhitespace(editor.ij, offset, dir)
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ 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.OperatorArguments
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
@ -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.vimStateMachine
|
||||
while (commandState.mode != VimStateMachine.Mode.COMMAND) {
|
||||
val commandState = this.vim.commandState
|
||||
while (commandState.mode != CommandState.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.vimStateMachine.popModes()
|
||||
this.vim.commandState.popModes()
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ fun Editor.exitVisualMode() {
|
||||
fun Editor.exitSelectMode(adjustCaretPosition: Boolean) {
|
||||
if (!this.inSelectMode) return
|
||||
|
||||
this.vim.vimStateMachine.popModes()
|
||||
this.vim.commandState.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.vimStateMachine.popModes()
|
||||
this.commandState.popModes()
|
||||
SelectionVimListenerSuppressor.lock().use {
|
||||
this.carets().forEach { vimCaret ->
|
||||
val caret = (vimCaret as IjVimCaret).caret
|
||||
|
@ -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.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
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 VimStateMachine.Mode mode = VimStateMachine.getInstance(new IjVimEditor(editor)).getMode();
|
||||
if (mode == VimStateMachine.Mode.VISUAL) {
|
||||
final CommandState.Mode mode = CommandState.getInstance(new IjVimEditor(editor)).getMode();
|
||||
if (mode == CommandState.Mode.VISUAL) {
|
||||
if (closingTagTextRange.getStartOffset() == selectionEndWithoutNewline &&
|
||||
openingTag.getEndOffset() == selectionStart) {
|
||||
// Special case: if the inner tag is already selected we should like isOuter is active
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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 com.maddyhome.idea.vim.api.injector
|
||||
import java.util.*
|
||||
import java.util.stream.Collectors
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
/**
|
||||
* COMPATIBILITY-LAYER: Created a helper class
|
||||
*/
|
||||
object StringHelper {
|
||||
@JvmStatic
|
||||
fun parseKeys(string: String): List<KeyStroke> {
|
||||
return injector.parser.parseKeys(string)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun parseKeys(vararg string: String): List<KeyStroke> {
|
||||
return Arrays.stream(string).flatMap { o: String -> injector.parser.parseKeys(o).stream() }
|
||||
.collect(Collectors.toList())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isCloseKeyStroke(stroke: KeyStroke): Boolean {
|
||||
return stroke.isCloseKeyStroke()
|
||||
}
|
||||
}
|
@ -99,6 +99,5 @@ class UndoRedoHelper : UndoRedoBase() {
|
||||
while (check() && !changeListener.hasChanged) {
|
||||
action.run()
|
||||
}
|
||||
vimDocument.removeChangeListener(changeListener)
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,8 @@ 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.api.CaretRegisterStorageBase
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.ex.ExOutputModel
|
||||
import com.maddyhome.idea.vim.group.visual.VisualChange
|
||||
import com.maddyhome.idea.vim.group.visual.vimLeadSelectionOffset
|
||||
@ -74,12 +73,11 @@ var Caret.vimInsertStart: RangeMarker by userDataOr {
|
||||
this.offset
|
||||
)
|
||||
}
|
||||
var Caret.registerStorage: CaretRegisterStorageBase? by userDataCaretToEditor()
|
||||
|
||||
// ------------------ Editor
|
||||
fun unInitializeEditor(editor: Editor) {
|
||||
editor.vimLastSelectionType = null
|
||||
editor.vimStateMachine = null
|
||||
editor.vimCommandState = null
|
||||
editor.vimMorePanel = null
|
||||
editor.vimExOutput = null
|
||||
editor.vimLastHighlighters = null
|
||||
@ -93,7 +91,7 @@ var Editor.vimIncsearchCurrentMatchOffset: Int? by userData()
|
||||
* @see :help visualmode()
|
||||
*/
|
||||
var Editor.vimLastSelectionType: SelectionType? by userData()
|
||||
var Editor.vimStateMachine: VimStateMachine? by userData()
|
||||
var Editor.vimCommandState: CommandState? by userData()
|
||||
var Editor.vimEditorGroup: Boolean by userDataOr { false }
|
||||
var Editor.vimLineNumbersInitialState: Boolean by userDataOr { false }
|
||||
var Editor.vimHasRelativeLineNumbersInstalled: Boolean by userDataOr { false }
|
||||
@ -105,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: VimStateMachine.Mode? by userData()
|
||||
var Editor.vimChangeActionSwitchMode: CommandState.Mode? by userData()
|
||||
|
||||
/**
|
||||
* Function for delegated properties.
|
||||
|
@ -19,6 +19,8 @@
|
||||
package com.maddyhome.idea.vim.key
|
||||
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.common.Node
|
||||
import com.maddyhome.idea.vim.common.addLeafs
|
||||
|
||||
fun <T> Node<T>.addLeafs(keys: String, actionHolder: T) {
|
||||
addLeafs(injector.parser.parseKeys(keys), actionHolder)
|
||||
|
@ -32,17 +32,16 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
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.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.group.NotificationService
|
||||
import com.maddyhome.idea.vim.helper.EditorDataContext
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
import com.maddyhome.idea.vim.helper.inNormalMode
|
||||
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
|
||||
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
|
||||
@ -71,7 +70,7 @@ object IdeaSpecifics {
|
||||
//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
|
||||
val id: String? = ActionManager.getInstance().getId(action)
|
||||
VimPlugin.getNotifications(dataContext.getData(CommonDataKeys.PROJECT)).notifyActionId(id)
|
||||
}
|
||||
}
|
||||
@ -89,8 +88,8 @@ object IdeaSpecifics {
|
||||
}
|
||||
) {
|
||||
editor?.let {
|
||||
val commandState = it.vim.vimStateMachine
|
||||
while (commandState.mode != VimStateMachine.Mode.COMMAND) {
|
||||
val commandState = it.vim.commandState
|
||||
while (commandState.mode != CommandState.Mode.COMMAND) {
|
||||
commandState.popModes()
|
||||
}
|
||||
VimPlugin.getChange().insertBeforeCursor(it.vim, dataContext.vim)
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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 != VimStateMachine.SubMode.NONE) {
|
||||
if (editor.subMode != CommandState.SubMode.NONE) {
|
||||
caretModel.removeSecondaryCarets()
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,11 @@ import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.LineDeleteShift
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
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.SelectionType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.common.EditorLine
|
||||
import com.maddyhome.idea.vim.common.IndentConfig
|
||||
import com.maddyhome.idea.vim.common.OperatedRange
|
||||
@ -41,6 +40,7 @@ import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.common.VimRange
|
||||
import com.maddyhome.idea.vim.common.including
|
||||
import com.maddyhome.idea.vim.common.offset
|
||||
import com.maddyhome.idea.vim.group.ChangeGroup
|
||||
import com.maddyhome.idea.vim.group.MotionGroup
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.inlayAwareVisualColumn
|
||||
@ -62,7 +62,7 @@ fun changeRange(
|
||||
var col = 0
|
||||
var lines = 0
|
||||
if (type === SelectionType.BLOCK_WISE) {
|
||||
lines = VimChangeGroupBase.getLinesCountInVisualBlock(IjVimEditor(editor), range)
|
||||
lines = ChangeGroup.getLinesCountInVisualBlock(IjVimEditor(editor), range)
|
||||
col = editor.offsetToLogicalPosition(range.startOffset).column
|
||||
if (caret.vimLastColumn == VimMotionGroupBase.LAST_COLUMN) {
|
||||
col = VimMotionGroupBase.LAST_COLUMN
|
||||
@ -103,7 +103,7 @@ fun changeRange(
|
||||
if (type == SelectionType.BLOCK_WISE) {
|
||||
VimPlugin.getChange().setInsertRepeat(lines, col, false)
|
||||
}
|
||||
editor.vimChangeActionSwitchMode = VimStateMachine.Mode.INSERT
|
||||
editor.vimChangeActionSwitchMode = CommandState.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, VimStateMachine.Mode.INSERT)
|
||||
VimPlugin.getChange().initInsert(editor, context, CommandState.Mode.INSERT)
|
||||
|
||||
if (!VimStateMachine.getInstance(editor).isDotRepeatInProgress) {
|
||||
if (!CommandState.getInstance(editor).isDotRepeatInProgress) {
|
||||
for (vimCaret in editor.carets()) {
|
||||
val caret = (vimCaret as IjVimCaret).caret
|
||||
val line = vimCaret.getLine()
|
||||
|
@ -22,10 +22,7 @@ import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.intellij.openapi.editor.VisualPosition
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.CaretRegisterStorage
|
||||
import com.maddyhome.idea.vim.api.CaretRegisterStorageBase
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimCaretBase
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.VimLogicalPosition
|
||||
import com.maddyhome.idea.vim.api.VimVisualPosition
|
||||
@ -41,23 +38,13 @@ import com.maddyhome.idea.vim.group.visual.vimSetSystemSelectionSilently
|
||||
import com.maddyhome.idea.vim.group.visual.vimUpdateEditorSelection
|
||||
import com.maddyhome.idea.vim.helper.inlayAwareVisualColumn
|
||||
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
|
||||
import com.maddyhome.idea.vim.helper.registerStorage
|
||||
import com.maddyhome.idea.vim.helper.vimInsertStart
|
||||
import com.maddyhome.idea.vim.helper.vimLastColumn
|
||||
import com.maddyhome.idea.vim.helper.vimLastVisualOperatorRange
|
||||
import com.maddyhome.idea.vim.helper.vimLine
|
||||
import com.maddyhome.idea.vim.helper.vimSelectionStart
|
||||
|
||||
class IjVimCaret(val caret: Caret) : VimCaretBase() {
|
||||
override val registerStorage: CaretRegisterStorage
|
||||
get() {
|
||||
var storage = this.caret.registerStorage
|
||||
if (storage == null) {
|
||||
storage = CaretRegisterStorageBase(editor.primaryCaret().ij == caret)
|
||||
this.caret.registerStorage = storage
|
||||
}
|
||||
return storage
|
||||
}
|
||||
class IjVimCaret(val caret: Caret) : VimCaret {
|
||||
override val editor: VimEditor
|
||||
get() = IjVimEditor(caret.editor)
|
||||
override val offset: Offset
|
||||
|
@ -38,9 +38,9 @@ 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.OperatorArguments
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.common.EditorLine
|
||||
import com.maddyhome.idea.vim.common.LiveRange
|
||||
import com.maddyhome.idea.vim.common.Offset
|
||||
@ -72,7 +72,7 @@ class IjVimEditor(editor: Editor) : MutableLinearEditor() {
|
||||
val originalEditor = editor
|
||||
|
||||
override val lfMakesNewLine: Boolean = true
|
||||
override var vimChangeActionSwitchMode: VimStateMachine.Mode?
|
||||
override var vimChangeActionSwitchMode: CommandState.Mode?
|
||||
get() = editor.vimChangeActionSwitchMode
|
||||
set(value) {
|
||||
editor.vimChangeActionSwitchMode = value
|
||||
|
@ -3,7 +3,6 @@ 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
|
||||
@ -40,7 +39,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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.common.VimMachine
|
||||
import com.maddyhome.idea.vim.diagnostic.VimLogger
|
||||
import com.maddyhome.idea.vim.ex.ExOutputModel
|
||||
@ -64,11 +63,11 @@ 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.vimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.vimCommandState
|
||||
import com.maddyhome.idea.vim.history.VimHistory
|
||||
import com.maddyhome.idea.vim.macro.VimMacro
|
||||
import com.maddyhome.idea.vim.mark.VimMarkGroup
|
||||
import com.maddyhome.idea.vim.vimscript.services.OptionService
|
||||
import com.maddyhome.idea.vim.options.OptionService
|
||||
import com.maddyhome.idea.vim.put.VimPut
|
||||
import com.maddyhome.idea.vim.register.VimRegisterGroup
|
||||
import com.maddyhome.idea.vim.ui.VimRcFileState
|
||||
@ -76,7 +75,7 @@ import com.maddyhome.idea.vim.undo.VimUndoRedo
|
||||
import com.maddyhome.idea.vim.vimscript.Executor
|
||||
import com.maddyhome.idea.vim.vimscript.services.FunctionStorage
|
||||
import com.maddyhome.idea.vim.vimscript.services.PatternService
|
||||
import com.maddyhome.idea.vim.vimscript.services.VariableService
|
||||
import com.maddyhome.idea.vim.vimscript.services.VimVariableService
|
||||
import com.maddyhome.idea.vim.yank.VimYankGroup
|
||||
|
||||
class IjVimInjector : VimInjectorBase() {
|
||||
@ -161,7 +160,7 @@ class IjVimInjector : VimInjectorBase() {
|
||||
|
||||
override val functionService: VimscriptFunctionService
|
||||
get() = FunctionStorage
|
||||
override val variableService: VariableService
|
||||
override val variableService: VimVariableService
|
||||
get() = service()
|
||||
override val vimrcFileState: VimrcFileState
|
||||
get() = VimRcFileState
|
||||
@ -180,23 +179,15 @@ class IjVimInjector : VimInjectorBase() {
|
||||
override val vimStorageService: VimStorageService
|
||||
get() = service()
|
||||
|
||||
override fun commandStateFor(editor: VimEditor): VimStateMachine {
|
||||
var res = editor.ij.vimStateMachine
|
||||
override fun commandStateFor(editor: VimEditor): CommandState {
|
||||
var res = editor.ij.vimCommandState
|
||||
if (res == null) {
|
||||
res = VimStateMachine(editor)
|
||||
editor.ij.vimStateMachine = res
|
||||
res = CommandState(editor)
|
||||
editor.ij.vimCommandState = 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
|
||||
|
@ -110,17 +110,6 @@ class IjVimSearchHelper : VimSearchHelper {
|
||||
)
|
||||
}
|
||||
|
||||
override fun findNextWordEnd(
|
||||
chars: CharSequence,
|
||||
pos: Int,
|
||||
size: Int,
|
||||
count: Int,
|
||||
bigWord: Boolean,
|
||||
spaceWords: Boolean,
|
||||
): Int {
|
||||
return SearchHelper.findNextWordEnd(chars, pos, size, count, bigWord, spaceWords)
|
||||
}
|
||||
|
||||
override fun findNextWord(editor: VimEditor, searchFrom: Int, count: Int, bigWord: Boolean): Int {
|
||||
return SearchHelper.findNextWord(
|
||||
(editor as IjVimEditor).editor,
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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.OptionConstants.Companion.timeoutName
|
||||
import com.maddyhome.idea.vim.options.OptionConstants.Companion.timeoutlenName
|
||||
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 timeout: ToggleOption
|
||||
get() = (injector.optionService as IjVimOptionService).getRawOption(timeoutName) as ToggleOption
|
||||
val timeoutlen: NumberOption
|
||||
get() = (injector.optionService as IjVimOptionService).getRawOption(timeoutlenName) as NumberOption
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
@ -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.command.MappingMode
|
||||
import com.maddyhome.idea.vim.common.MappingMode
|
||||
import com.maddyhome.idea.vim.key.MappingOwner
|
||||
import com.maddyhome.idea.vim.key.ToKeysMappingInfo
|
||||
|
||||
|
@ -20,8 +20,8 @@ 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.isCloseKeyStroke
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import java.awt.KeyEventDispatcher
|
||||
import java.awt.KeyboardFocusManager
|
||||
import java.awt.Toolkit
|
||||
@ -62,7 +62,7 @@ object ModalEntry {
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
if (editor.vimStateMachine.isRecording) {
|
||||
if (editor.commandState.isRecording) {
|
||||
KeyHandler.getInstance().modalEntryKeys += stroke
|
||||
}
|
||||
if (!processor(stroke)) {
|
||||
|
@ -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.vimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
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.vimStateMachine
|
||||
val editorState = editor.vim.commandState
|
||||
return EngineStringHelper.toPrintableCharacters(editorState.commandBuilder.keys + editorState.mappingState.keys)
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.vimscript.model.functions.handlers
|
||||
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.ex.ExException
|
||||
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.VimList
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
|
||||
import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler
|
||||
|
||||
class JoinFunctionHandler : FunctionHandler() {
|
||||
override val name: String = "join"
|
||||
override val minimumNumberOfArguments: Int = 1
|
||||
override val maximumNumberOfArguments: Int = 2
|
||||
|
||||
override fun doFunction(
|
||||
argumentValues: List<Expression>,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
vimContext: VimLContext,
|
||||
): VimDataType {
|
||||
val firstArgument = argumentValues[0].evaluate(editor, context, vimContext)
|
||||
if (firstArgument !is VimList) {
|
||||
throw ExException("E714: List required")
|
||||
}
|
||||
val secondArgument = argumentValues.getOrNull(1)?.evaluate(editor, context, vimContext) ?: VimString(" ")
|
||||
return VimString(firstArgument.values.joinToString(secondArgument.asString()) { it.toString() })
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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.vimscript.model.functions.handlers
|
||||
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
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.VimString
|
||||
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
|
||||
import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler
|
||||
import java.util.*
|
||||
|
||||
class TolowerFunctionHandler : FunctionHandler() {
|
||||
override val name: String = "tolower"
|
||||
override val minimumNumberOfArguments: Int = 1
|
||||
override val maximumNumberOfArguments: Int = 1
|
||||
|
||||
override fun doFunction(
|
||||
argumentValues: List<Expression>,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
vimContext: VimLContext,
|
||||
): VimDataType {
|
||||
val argumentString = argumentValues[0].evaluate(editor, context, vimContext).asString()
|
||||
return VimString(argumentString.lowercase(Locale.getDefault()))
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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.vimscript.model.functions.handlers
|
||||
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
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.VimString
|
||||
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
|
||||
import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler
|
||||
import java.util.*
|
||||
|
||||
class ToupperFunctionHandler : FunctionHandler() {
|
||||
override val name: String = "toupper"
|
||||
override val minimumNumberOfArguments: Int = 1
|
||||
override val maximumNumberOfArguments: Int = 1
|
||||
|
||||
override fun doFunction(
|
||||
argumentValues: List<Expression>,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
vimContext: VimLContext,
|
||||
): VimDataType {
|
||||
val argumentString = argumentValues[0].evaluate(editor, context, vimContext).asString()
|
||||
return VimString(argumentString.uppercase(Locale.getDefault()))
|
||||
}
|
||||
}
|
@ -25,9 +25,9 @@ import com.intellij.codeInsight.lookup.impl.LookupImpl
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.helper.editorMode
|
||||
import com.maddyhome.idea.vim.helper.hasBlockOrUnderscoreCaret
|
||||
import com.maddyhome.idea.vim.helper.hasVisualSelection
|
||||
import com.maddyhome.idea.vim.helper.mode
|
||||
import com.maddyhome.idea.vim.helper.subMode
|
||||
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -42,12 +42,12 @@ object IdeaRefactorModeHelper {
|
||||
|
||||
fun correctSelection(editor: Editor) {
|
||||
val action: () -> Unit = {
|
||||
if (!editor.editorMode.hasVisualSelection && editor.selectionModel.hasSelection()) {
|
||||
if (!editor.mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
|
||||
SelectionVimListenerSuppressor.lock().use {
|
||||
editor.selectionModel.removeSelection()
|
||||
}
|
||||
}
|
||||
if (editor.editorMode.hasVisualSelection && editor.selectionModel.hasSelection()) {
|
||||
if (editor.mode.hasVisualSelection && editor.selectionModel.hasSelection()) {
|
||||
val autodetectedSubmode = VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim)
|
||||
if (editor.subMode != autodetectedSubmode) {
|
||||
// Update the submode
|
||||
|
@ -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 ${ctx.text}")
|
||||
throw ExException("Could not create a range")
|
||||
}
|
||||
return ranges
|
||||
}
|
||||
@ -180,7 +180,7 @@ object CommandVisitor : VimscriptBaseVisitor<Command>() {
|
||||
override fun visitLet1Command(ctx: VimscriptParser.Let1CommandContext): Command {
|
||||
val ranges: Ranges = parseRanges(ctx.range())
|
||||
val variable: Expression = expressionVisitor.visit(ctx.expr(0))
|
||||
val operator = getByValue(ctx.assignmentOperator().text)
|
||||
val operator = getByValue(ctx.assignmentOperator.text)
|
||||
val expression: Expression = expressionVisitor.visit(ctx.expr(1))
|
||||
return LetCommand(ranges, variable, operator, expression, true)
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ package com.maddyhome.idea.vim.vimscript.services
|
||||
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo
|
||||
import com.maddyhome.idea.vim.api.VimOptionServiceBase
|
||||
import com.maddyhome.idea.vim.option.ToggleOption
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.StringOption
|
||||
import com.maddyhome.idea.vim.options.ToggleOption
|
||||
|
||||
internal class IjVimOptionService : VimOptionServiceBase() {
|
||||
|
||||
|
@ -33,7 +33,7 @@ import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||
import com.maddyhome.idea.vim.vimscript.model.expressions.Scope
|
||||
import com.maddyhome.idea.vim.vimscript.model.expressions.Variable
|
||||
|
||||
class IjVariableService : VimVariableServiceBase() {
|
||||
internal class VimVariableServiceImpl : VimVariableServiceBase() {
|
||||
override fun storeVariable(variable: Variable, value: VimDataType, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext) {
|
||||
super.storeVariable(variable, value, editor, context, vimContext)
|
||||
|
@ -26,13 +26,13 @@
|
||||
serviceInterface="com.maddyhome.idea.vim.api.VimVisualMotionGroup"/>
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.group.copy.YankGroup"/>
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.group.copy.PutGroup"/>
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.vimscript.services.IjVariableService"
|
||||
serviceInterface="com.maddyhome.idea.vim.vimscript.services.VariableService"/>
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.vimscript.services.VimVariableServiceImpl"
|
||||
serviceInterface="com.maddyhome.idea.vim.vimscript.services.VimVariableService"/>
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.group.IjStatisticsService"
|
||||
serviceInterface="com.maddyhome.idea.vim.api.VimStatistics"/>
|
||||
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.vimscript.services.IjVimOptionService"
|
||||
serviceInterface="com.maddyhome.idea.vim.vimscript.services.OptionService"/>
|
||||
serviceInterface="com.maddyhome.idea.vim.options.OptionService"/>
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.group.IjVimStorageService"
|
||||
serviceInterface="com.maddyhome.idea.vim.api.VimStorageService"/>
|
||||
<applicationService serviceImplementation="com.maddyhome.idea.vim.group.IjVimSystemInfoService"
|
||||
|
@ -11,8 +11,5 @@
|
||||
<vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.FuncrefFunctionHandler" name="funcref"/>
|
||||
<vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.HasFunctionHandler" name="has"/>
|
||||
<vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.SubmatchFunctionHandler" name="submatch"/>
|
||||
<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"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
@ -24,15 +24,16 @@ 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.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.group.visual.VimVisualTimer;
|
||||
import com.maddyhome.idea.vim.helper.EditorDataContext;
|
||||
import com.maddyhome.idea.vim.helper.RunnableHelper;
|
||||
import com.maddyhome.idea.vim.helper.TestInputModel;
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor;
|
||||
import com.maddyhome.idea.vim.options.OptionScope;
|
||||
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel;
|
||||
import com.maddyhome.idea.vim.options.OptionScope;
|
||||
import com.maddyhome.idea.vim.vimscript.services.VimVariableServiceImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -62,7 +63,7 @@ public abstract class JavaVimTestCase extends JavaCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ExEntryPanel.getInstance().deactivate(false);
|
||||
VimPlugin.getVariableService().clear();
|
||||
((VimVariableServiceImpl) VimPlugin.getVariableService()).clear();
|
||||
Timer swingTimer = VimVisualTimer.INSTANCE.getSwingTimer();
|
||||
if (swingTimer != null) {
|
||||
swingTimer.stop();
|
||||
@ -106,8 +107,8 @@ public abstract class JavaVimTestCase extends JavaCodeInsightFixtureTestCase {
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void assertMode(@NotNull VimStateMachine.Mode expectedMode) {
|
||||
final VimStateMachine.Mode mode = VimStateMachine.getInstance(new IjVimEditor(myFixture.getEditor())).getMode();
|
||||
public void assertMode(@NotNull CommandState.Mode expectedMode) {
|
||||
final CommandState.Mode mode = CommandState.getInstance(new IjVimEditor(myFixture.getEditor())).getMode();
|
||||
assertEquals(expectedMode, mode);
|
||||
}
|
||||
|
||||
|
@ -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.vimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
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.vimStateMachine.toVimNotation()
|
||||
val ideavimState = editor.vim.commandState.toVimNotation()
|
||||
val neovimState = neovimApi.mode.get().mode
|
||||
assertEquals(neovimState, ideavimState)
|
||||
}
|
||||
|
@ -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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.key.CommandNode
|
||||
import com.maddyhome.idea.vim.key.CommandPartNode
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("l", before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) {
|
||||
motionRightAction = VIM_ACTIONS_EP.extensions().filter { it.actionId == "VimPreviousTabAction" }.findFirst().get()
|
||||
|
||||
assertNotNull(getCommandNode())
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.helper.editorMode
|
||||
import com.maddyhome.idea.vim.helper.mode
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
|
||||
@ -77,10 +77,10 @@ inline fun waitAndAssert(timeInMillis: Int = 1000, condition: () -> Boolean) {
|
||||
|
||||
fun waitAndAssertMode(
|
||||
fixture: CodeInsightTestFixture,
|
||||
mode: VimStateMachine.Mode,
|
||||
mode: CommandState.Mode,
|
||||
timeInMillis: Int = (VimPlugin.getOptionService().getOptionValue(OptionScope.GLOBAL, OptionConstants.visualdelayName) as VimInt).value + 1000,
|
||||
) {
|
||||
waitAndAssert(timeInMillis) { fixture.editor.editorMode == mode }
|
||||
waitAndAssert(timeInMillis) { fixture.editor.mode == mode }
|
||||
}
|
||||
|
||||
fun assertDoesntChange(timeInMillis: Int = 1000, condition: () -> Boolean) {
|
||||
|
@ -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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine.SubMode
|
||||
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.ex.ExException
|
||||
import com.maddyhome.idea.vim.ex.ExOutputModel.Companion.getInstance
|
||||
import com.maddyhome.idea.vim.group.visual.VimVisualTimer.swingTimer
|
||||
@ -61,9 +61,9 @@ import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.GuicursorChangeListener
|
||||
import com.maddyhome.idea.vim.helper.RunnableHelper.runWriteCommand
|
||||
import com.maddyhome.idea.vim.helper.TestInputModel
|
||||
import com.maddyhome.idea.vim.helper.editorMode
|
||||
import com.maddyhome.idea.vim.helper.getGuiCursorMode
|
||||
import com.maddyhome.idea.vim.helper.inBlockSubMode
|
||||
import com.maddyhome.idea.vim.helper.mode
|
||||
import com.maddyhome.idea.vim.helper.subMode
|
||||
import com.maddyhome.idea.vim.key.MappingOwner
|
||||
import com.maddyhome.idea.vim.key.ToKeysMappingInfo
|
||||
@ -77,6 +77,7 @@ import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimFuncref
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
|
||||
import com.maddyhome.idea.vim.vimscript.parser.errors.IdeavimErrorListener
|
||||
import com.maddyhome.idea.vim.vimscript.services.VimVariableServiceImpl
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.Assert
|
||||
import java.awt.event.KeyEvent
|
||||
@ -136,7 +137,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
SelectionVimListenerSuppressor.lock().use { myFixture.tearDown() }
|
||||
ExEntryPanel.getInstance().deactivate(false)
|
||||
VimPlugin.getVariableService().clear()
|
||||
(VimPlugin.getVariableService() as VimVariableServiceImpl).clear()
|
||||
VimFuncref.lambdaCounter = 0
|
||||
VimFuncref.anonymousCounter = 0
|
||||
IdeavimErrorListener.testLogger.clear()
|
||||
@ -438,8 +439,8 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
fun assertMode(expectedMode: VimStateMachine.Mode) {
|
||||
val mode = myFixture.editor.editorMode
|
||||
fun assertMode(expectedMode: CommandState.Mode) {
|
||||
val mode = myFixture.editor.mode
|
||||
Assert.assertEquals(expectedMode, mode)
|
||||
}
|
||||
|
||||
@ -504,14 +505,14 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
before: String,
|
||||
after: String,
|
||||
) {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, SubMode.NONE)
|
||||
}
|
||||
|
||||
fun doTest(
|
||||
keys: List<String>,
|
||||
before: String,
|
||||
after: String,
|
||||
modeAfter: VimStateMachine.Mode,
|
||||
modeAfter: CommandState.Mode,
|
||||
subModeAfter: SubMode,
|
||||
) {
|
||||
doTest(keys.joinToString(separator = ""), before, after, modeAfter, subModeAfter)
|
||||
@ -521,7 +522,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
keys: String,
|
||||
before: String,
|
||||
after: String,
|
||||
modeAfter: VimStateMachine.Mode,
|
||||
modeAfter: CommandState.Mode,
|
||||
subModeAfter: SubMode,
|
||||
) {
|
||||
configureByText(before)
|
||||
@ -535,7 +536,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
keys: String,
|
||||
before: String,
|
||||
after: String,
|
||||
modeAfter: VimStateMachine.Mode,
|
||||
modeAfter: CommandState.Mode,
|
||||
subModeAfter: SubMode,
|
||||
fileType: FileType,
|
||||
) {
|
||||
@ -553,7 +554,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
keys: String,
|
||||
before: String,
|
||||
after: String,
|
||||
modeAfter: VimStateMachine.Mode,
|
||||
modeAfter: CommandState.Mode,
|
||||
subModeAfter: SubMode,
|
||||
fileName: String,
|
||||
) {
|
||||
@ -567,7 +568,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
NeovimTesting.assertState(myFixture.editor, this)
|
||||
}
|
||||
|
||||
protected fun performTest(keys: String, after: String, modeAfter: VimStateMachine.Mode, subModeAfter: SubMode) {
|
||||
protected fun performTest(keys: String, after: String, modeAfter: CommandState.Mode, subModeAfter: SubMode) {
|
||||
typeText(injector.parser.parseKeys(keys))
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
@Suppress("IdeaVimAssertState")
|
||||
@ -579,7 +580,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
keys: List<KeyStroke>,
|
||||
before: String,
|
||||
after: String?,
|
||||
modeAfter: VimStateMachine.Mode,
|
||||
modeAfter: CommandState.Mode,
|
||||
subModeAfter: SubMode,
|
||||
afterEditorInitialized: (Editor) -> Unit,
|
||||
) {
|
||||
@ -596,7 +597,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
NeovimTesting.setRegister(register, keys, this)
|
||||
}
|
||||
|
||||
protected fun assertState(modeAfter: VimStateMachine.Mode, subModeAfter: SubMode) {
|
||||
protected fun assertState(modeAfter: CommandState.Mode, subModeAfter: SubMode) {
|
||||
assertMode(modeAfter)
|
||||
assertSubMode(subModeAfter)
|
||||
assertCaretsVisualAttributes()
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"), "abc${c}d\n", "abcd12\n", CommandState.Mode.COMMAND,
|
||||
CommandState.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", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"abc${c}d\n", "abcd\n12\n", CommandState.Mode.COMMAND, CommandState.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", VimStateMachine.Mode.INSERT_VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER
|
||||
"12${c}345", "12${s}${c}3${se}45", CommandState.Mode.INSERT_VISUAL, CommandState.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", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"12${c}345", "12${c}345", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
fun testInsertSingleCommandAndNewLineInserting4() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "v", "d"),
|
||||
"12${c}345", "12${c}45", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"12${c}345", "12${c}45", CommandState.Mode.INSERT, CommandState.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", VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER
|
||||
"12${c}345", "12${s}3${c}${se}45", CommandState.Mode.INSERT_SELECT, CommandState.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", VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER
|
||||
"12${c}345", "12${s}3${c}${se}45", CommandState.Mode.INSERT_SELECT, CommandState.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", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"12${c}345", "123${c}45", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -109,58 +109,58 @@ class ChangeActionTest : VimTestCase() {
|
||||
fun testInsertSingleCommand() {
|
||||
doTest(
|
||||
listOf("i", "def", "<C-O>", "d2h", "x"),
|
||||
"abc$c.\n", "abcdx.\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"abc$c.\n", "abcdx.\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// VIM-321 |d| |count|
|
||||
fun testDeleteEmptyRange() {
|
||||
doTest("d0", "${c}hello\n", "hello\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("d0", "${c}hello\n", "hello\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-157 |~|
|
||||
fun testToggleCharCase() {
|
||||
doTest("~~", "${c}hello world\n", "HEllo world\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("~~", "${c}hello world\n", "HEllo world\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-157 |~|
|
||||
fun testToggleCharCaseLineEnd() {
|
||||
doTest("~~", "hello wor${c}ld\n", "hello worLD\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("~~", "hello wor${c}ld\n", "hello worLD\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun testToggleCaseMotion() {
|
||||
doTest("g~w", "${c}FooBar Baz\n", "fOObAR Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("g~w", "${c}FooBar Baz\n", "fOObAR Baz\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun testChangeUpperCase() {
|
||||
doTest(
|
||||
"gUw", "${c}FooBar Baz\n", "FOOBAR Baz\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"gUw", "${c}FooBar Baz\n", "FOOBAR Baz\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
fun testChangeLowerCase() {
|
||||
doTest("guw", "${c}FooBar Baz\n", "foobar Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("guw", "${c}FooBar Baz\n", "foobar Baz\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun testToggleCaseVisual() {
|
||||
doTest(
|
||||
"ve~", "${c}FooBar Baz\n", "fOObAR Baz\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"ve~", "${c}FooBar Baz\n", "fOObAR Baz\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
fun testChangeUpperCaseVisual() {
|
||||
doTest(
|
||||
"veU", "${c}FooBar Baz\n", "FOOBAR Baz\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"veU", "${c}FooBar Baz\n", "FOOBAR Baz\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
fun testChangeLowerCaseVisual() {
|
||||
doTest(
|
||||
"veu", "${c}FooBar Baz\n", "foobar Baz\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"veu", "${c}FooBar Baz\n", "foobar Baz\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
four
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
assertOffset(4)
|
||||
}
|
||||
@ -217,8 +217,8 @@ class ChangeActionTest : VimTestCase() {
|
||||
three
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
three
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
"""one
|
||||
three
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
assertOffset(3)
|
||||
}
|
||||
@ -266,16 +266,16 @@ class ChangeActionTest : VimTestCase() {
|
||||
three four
|
||||
|
||||
""".trimIndent(),
|
||||
"one four\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"one four\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// VIM-1380 |d| |w| |count|
|
||||
fun testDeleteTwoWordsAtLastChar() {
|
||||
doTest(
|
||||
"d2w", "on${c}e two three\n", "on${c}three\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"d2w", "on${c}e two three\n", "on${c}three\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -289,8 +289,8 @@ class ChangeActionTest : VimTestCase() {
|
||||
"""foo
|
||||
, baz
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -308,8 +308,8 @@ class ChangeActionTest : VimTestCase() {
|
||||
baz
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
bar
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
assertOffset(1)
|
||||
}
|
||||
@ -341,7 +341,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
two
|
||||
|
||||
""".trimIndent(),
|
||||
"two\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"two\n", CommandState.Mode.COMMAND, CommandState.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", VimStateMachine.Mode.INSERT,
|
||||
VimStateMachine.SubMode.NONE
|
||||
listOf("A", ", ", "<C-R>", "a", "!"), "${c}Hello\n", "Hello, World!\n", CommandState.Mode.INSERT,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
fun testInsertNewLineAboveFirstLine() {
|
||||
doTest(
|
||||
listOf("O", "bar"),
|
||||
"fo${c}o\n", "bar\nfoo\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"fo${c}o\n", "bar\nfoo\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
fun testVisualSelectionRightMargin() {
|
||||
doTest(
|
||||
listOf("v", "k\$d"),
|
||||
"foo\n${c}bar\n", "fooar\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"foo\n${c}bar\n", "fooar\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
quux
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
quux
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ quux
|
||||
""" a 1 b 2 c 3
|
||||
quux
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ quux
|
||||
""" a 1 b 2 c 3
|
||||
quux
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ quux
|
||||
|
||||
bar
|
||||
""".trimIndent(),
|
||||
"foo bar", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"foo bar", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -462,7 +462,7 @@ quux
|
||||
foo
|
||||
bar
|
||||
""".trimIndent(),
|
||||
"foo bar", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"foo bar", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ quux
|
||||
""" a 1 b 2 c 3
|
||||
quux
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -492,14 +492,14 @@ quux
|
||||
""" a 1 b 2 c 3
|
||||
quux
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
fun testDeleteCharVisualBlockOnLastCharOfLine() {
|
||||
doTest(
|
||||
listOf("<C-V>", "x"),
|
||||
"fo${c}o\n", "fo\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"fo${c}o\n", "fo\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ quux
|
||||
}
|
||||
doTest(
|
||||
listOf("<C-V>", "j", "x"),
|
||||
"\n\n", "\n\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"\n\n", "\n\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -529,7 +529,7 @@ quux
|
||||
br
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ quux
|
||||
br
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -575,18 +575,18 @@ quux
|
||||
|
||||
// |r|
|
||||
fun testReplaceOneChar() {
|
||||
doTest("rx", "b${c}ar\n", "b${c}xr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("rx", "b${c}ar\n", "b${c}xr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |r|
|
||||
@VimBehaviorDiffers(originalVimAfter = "foXX${c}Xr\n")
|
||||
fun testReplaceMultipleCharsWithCount() {
|
||||
doTest("3rX", "fo${c}obar\n", "fo${c}XXXr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("3rX", "fo${c}obar\n", "fo${c}XXXr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |r|
|
||||
fun testReplaceMultipleCharsWithCountPastEndOfLine() {
|
||||
doTest("6rX", "fo${c}obar\n", "fo${c}obar\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("6rX", "fo${c}obar\n", "fo${c}obar\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |r|
|
||||
@ -604,7 +604,7 @@ quux
|
||||
ZZZZZz
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -619,7 +619,7 @@ foobaz
|
||||
bar
|
||||
foobaz
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -635,20 +635,20 @@ foobaz
|
||||
r
|
||||
foobaz
|
||||
""",
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// |s|
|
||||
fun testReplaceOneCharWithText() {
|
||||
doTest("sxy<Esc>", "b${c}ar\n", "bx${c}yr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("sxy<Esc>", "b${c}ar\n", "bx${c}yr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |s|
|
||||
fun testReplaceMultipleCharsWithTextWithCount() {
|
||||
doTest(
|
||||
"3sxy<Esc>",
|
||||
"fo${c}obar\n", "fox${c}yr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"fo${c}obar\n", "fox${c}yr\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -666,13 +666,13 @@ foobaz
|
||||
biff
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// |R|
|
||||
fun testReplaceMode() {
|
||||
doTest("Rbaz<Esc>", "foo${c}bar\n", "fooba${c}z\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("Rbaz<Esc>", "foo${c}bar\n", "fooba${c}z\n", CommandState.Mode.COMMAND, CommandState.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", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zddd\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -689,8 +689,8 @@ foobaz
|
||||
fun testInsertModeSwitchToReplaceModeAndBack() {
|
||||
doTest(
|
||||
"iXXX<Ins>YYY<Ins>ZZZ<Esc>",
|
||||
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zcccddd\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zcccddd\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -709,7 +709,7 @@ foobaz
|
||||
fo${c}o quux
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -917,17 +917,17 @@ and some text after"""
|
||||
fun testRepeatChangeWordDoesNotBreakNextRepeatFind() {
|
||||
doTest(
|
||||
"fXcfYPATATA<Esc>fX.;.", "${c}aaaaXBBBBYaaaaaaaXBBBBYaaaaaaXBBBBYaaaaaaaa\n",
|
||||
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
fun testRepeatReplace() {
|
||||
configureByText("${c}foobarbaz spam\n")
|
||||
typeText(injector.parser.parseKeys("R"))
|
||||
assertMode(VimStateMachine.Mode.REPLACE)
|
||||
assertMode(CommandState.Mode.REPLACE)
|
||||
typeText(injector.parser.parseKeys("FOO" + "<Esc>" + "l" + "2."))
|
||||
assertState("FOOFOOFO${c}O spam\n")
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
}
|
||||
|
||||
fun testDownMovementAfterDeletionToStart() {
|
||||
@ -941,8 +941,8 @@ and some text after"""
|
||||
psum dolor sit amet
|
||||
${c}lorem ipsum dolor sit amet
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -957,8 +957,8 @@ and some text after"""
|
||||
ipsum dolor sit amet
|
||||
${c}lorem ipsum dolor sit amet
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -973,8 +973,8 @@ and some text after"""
|
||||
ipsum dolor sit amet
|
||||
${c}lorem ipsum dolor sit amet
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -989,8 +989,8 @@ and some text after"""
|
||||
ipsum dolor sit amet
|
||||
${c}lorem ipsum dolor sit amet
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -1005,8 +1005,8 @@ and some text after"""
|
||||
${c}lorem ipsum dolor sit amet
|
||||
psum dolor sit amet
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -1021,8 +1021,8 @@ and some text after"""
|
||||
${c}lorem ipsum dolor sit amet
|
||||
ipsum dolor sit amet
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -1040,7 +1040,7 @@ and some text after"""
|
||||
${c}lorem ipsum dolor sit amet
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -1059,7 +1059,7 @@ and some text after"""
|
||||
gaganis ${c}gaganis gaganis
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -1075,7 +1075,7 @@ and some text after"""
|
||||
line 1
|
||||
${c}line 3
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
package org.jetbrains.plugins.ideavim.action;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
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", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "0", "1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementHexZero() {
|
||||
doTest("<C-A>", "0x0", "0x1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "0x0", "0x1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementZero() {
|
||||
doTest("<C-X>", "0", "-1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-X>", "0", "-1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementDecimal() {
|
||||
doTest("<C-A>", "199", "200", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "199", "200", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementDecimal() {
|
||||
doTest("<C-X>", "1000", "999", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-X>", "1000", "999", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementOctal() {
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0477", "0500", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0477", "0500", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementOctal() {
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "010", "007", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "010", "007", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementHex() {
|
||||
doTest("<C-A>", "0xff", "0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "0xff", "0x100", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementHex() {
|
||||
doTest("<C-X>", "0xa100", "0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-X>", "0xa100", "0xa0ff", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementNegativeDecimal() {
|
||||
doTest("<C-A>", "-199", "-198", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "-199", "-198", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementNegativeDecimal() {
|
||||
doTest("<C-X>", "-1000", "-1001", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-X>", "-1000", "-1001", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementNegativeOctal() {
|
||||
// Minus isn't processed
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "-0477", "-0500", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "-0477", "-0500", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementNegativeOctal() {
|
||||
// Minus isn't processed
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "-010", "-007", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "-010", "-007", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementNegativeHex() {
|
||||
doTest("<C-A>", "-0xff", "-0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "-0xff", "-0x100", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementNegativeHex() {
|
||||
doTest("<C-X>", "-0xa100", "-0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-X>", "-0xa100", "-0xa0ff", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementWithCount() {
|
||||
doTest("123<C-A>", "456", "579", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("123<C-A>", "456", "579", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testDecrementWithCount() {
|
||||
doTest("200<C-X>", "100", "-100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("200<C-X>", "100", "-100", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementAlphaWithoutNumberFormatAlpha() {
|
||||
doTest("<C-A>", "foo", "foo", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "foo", "foo", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementAlphaWithNumberFormatAlpha() {
|
||||
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "foo", "goo", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "foo", "goo", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementZWithNumberFormatAlpha() {
|
||||
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "zzz", "zzz", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "zzz", "zzz", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementXInHexNumberWithNumberFormatAlphaButNotHex() {
|
||||
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "0<caret>x1", "0y1", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "0<caret>x1", "0y1", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementXInHexNumberWithNumberFormatHexAlpha() {
|
||||
doTest(Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"), "0<caret>x1", "0x2", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"), "0<caret>x1", "0x2", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementHexNumberWithoutNumberFormatHex() {
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0x42", "1x42", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0x42", "1x42", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementOctalNumberWithoutNumberFormatOctal() {
|
||||
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "077", "078", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "077", "078", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementNegativeOctalNumberWithoutNumberFormatOctal() {
|
||||
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "-077", "-076", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest(Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "-077", "-076", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementHexPreservesCaseOfX() {
|
||||
doTest("<C-A>", "0X88", "0X89", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "0X88", "0X89", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementHexTakesCaseFromLastLetter() {
|
||||
doTest("<C-A>", "0xaB0", "0xAB1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "0xaB0", "0xAB1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
|
||||
public void testIncrementLocatesNumberOnTheSameLine() {
|
||||
doTest("<C-A>", "foo ->* bar 123\n", "foo ->* bar 12<caret>4\n", VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE);
|
||||
doTest("<C-A>", "foo ->* bar 123\n", "foo ->* bar 12<caret>4\n", CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE);
|
||||
}
|
||||
}
|
||||
|
@ -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.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
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(VimStateMachine.Mode.COMMAND);
|
||||
assertMode(CommandState.Mode.COMMAND);
|
||||
assertSelection(null);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
package org.jetbrains.plugins.ideavim.action
|
||||
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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(VimStateMachine.Mode.INSERT)
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@ -176,7 +176,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.INSERT)
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@ -198,7 +198,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.INSERT)
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
}
|
||||
|
||||
/*
|
||||
@ -255,7 +255,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
$c
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.INSERT)
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@ -274,7 +274,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@ -294,7 +294,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@ -315,7 +315,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.INSERT)
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@ -335,6 +335,6 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
}
|
||||
}
|
||||
|
@ -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.vimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
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.vimStateMachine
|
||||
val commandState = editor.vim.commandState
|
||||
assertFalse(commandState.isRecording)
|
||||
val registerGroup = VimPlugin.getRegister()
|
||||
val register = registerGroup.getRegister('a')
|
||||
|
@ -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.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
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", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE);
|
||||
"one two\n" + "thre<caret>ethree\n" + "four five\n", CommandState.Mode.COMMAND, CommandState.SubMode.NONE);
|
||||
}
|
||||
}
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.helper.vimCommandState
|
||||
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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("vv", contents, contents, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-198 |v_iw|
|
||||
@ -41,8 +41,8 @@ class MotionActionTest : VimTestCase() {
|
||||
"viw",
|
||||
fileContents,
|
||||
"one ${s}two${se}\n",
|
||||
VimStateMachine.Mode.VISUAL,
|
||||
VimStateMachine.SubMode.VISUAL_CHARACTER
|
||||
CommandState.Mode.VISUAL,
|
||||
CommandState.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, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
doTest("viW", fileContents, fileContentsAfter, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
assertSelection("two.three")
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class MotionActionTest : VimTestCase() {
|
||||
three
|
||||
|
||||
""".trimIndent()
|
||||
doTest(listOf("f", "<Esc>", "<Esc>"), content, content, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(listOf("f", "<Esc>", "<Esc>"), content, content, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
assertPluginError(true)
|
||||
assertOffset(2)
|
||||
}
|
||||
@ -71,9 +71,9 @@ class MotionActionTest : VimTestCase() {
|
||||
three
|
||||
|
||||
""".trimIndent()
|
||||
doTest(listOf("12", "<Esc>"), content, content, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(listOf("12", "<Esc>"), content, content, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
assertPluginError(false)
|
||||
val vimCommandState = myFixture.editor.vimStateMachine
|
||||
val vimCommandState = myFixture.editor.vimCommandState
|
||||
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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(listOf("14l", "2h"), before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |j| |k|
|
||||
@ -101,7 +101,7 @@ class MotionActionTest : VimTestCase() {
|
||||
four
|
||||
|
||||
""".trimIndent()
|
||||
doTest(listOf("2j", "k"), before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(listOf("2j", "k"), before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(listOf("f<Tab>"), before, after, CommandState.Mode.COMMAND, CommandState.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(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |v_as|
|
||||
@ -280,7 +280,7 @@ class MotionActionTest : VimTestCase() {
|
||||
P$c.
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |d| |v_ip|
|
||||
@ -302,7 +302,7 @@ class MotionActionTest : VimTestCase() {
|
||||
Bye.
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |d| |v_ap|
|
||||
@ -323,7 +323,7 @@ class MotionActionTest : VimTestCase() {
|
||||
Bye.
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |d| |v_a]|
|
||||
@ -336,7 +336,7 @@ class MotionActionTest : VimTestCase() {
|
||||
];
|
||||
"""
|
||||
val after = "foo = ;\n"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun testDeleteDoubleQuotedStringOddNumberOfQuotes() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "abc\"def${c}\"gh\"i"
|
||||
val after = "abc\"\"gh\"i"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |CTRL-V|
|
||||
@ -817,7 +817,7 @@ two
|
||||
${s}ba${se}r
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_BLOCK)
|
||||
}
|
||||
|
||||
// |CTRL-V|
|
||||
@ -833,7 +833,7 @@ two
|
||||
b${s}ar$se
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_BLOCK)
|
||||
}
|
||||
|
||||
// |CTRL-V|
|
||||
@ -851,7 +851,7 @@ two
|
||||
a${s}b$se
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-564 |g_|
|
||||
@ -880,8 +880,8 @@ two
|
||||
four
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -903,8 +903,8 @@ two
|
||||
four
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -924,7 +924,7 @@ two
|
||||
bar
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |v_>| |gv|
|
||||
@ -948,7 +948,7 @@ two
|
||||
""".trimIndent()
|
||||
)
|
||||
typeText(injector.parser.parseKeys(">"))
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
assertState(
|
||||
""" foo
|
||||
bar
|
||||
@ -963,7 +963,7 @@ two
|
||||
"""
|
||||
)
|
||||
typeText(injector.parser.parseKeys(">"))
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
assertState(
|
||||
""" foo
|
||||
bar
|
||||
@ -992,7 +992,7 @@ two
|
||||
bar
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
doTest(keys, before, after, CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
}
|
||||
|
||||
fun testVisualLineSelectDown() {
|
||||
@ -1006,7 +1006,7 @@ two
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.VISUAL)
|
||||
assertMode(CommandState.Mode.VISUAL)
|
||||
assertSelection(
|
||||
"""
|
||||
bar
|
||||
@ -1029,7 +1029,7 @@ two
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
assertMode(VimStateMachine.Mode.VISUAL)
|
||||
assertMode(CommandState.Mode.VISUAL)
|
||||
assertSelection(
|
||||
"""
|
||||
bar
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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.MappingMode
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.common.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(
|
||||
@ -271,7 +271,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
XXXXX${c}Xy the torrent of a mountain pass.
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR)
|
||||
@ -293,7 +293,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
${c}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun `test redo register feature`() {
|
||||
@ -331,7 +331,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
One
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
assertFalse(hasSelection())
|
||||
}
|
||||
|
||||
@ -71,7 +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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
assertFalse(hasSelection())
|
||||
}
|
||||
|
||||
@ -88,12 +88,12 @@ class UndoActionTest : VimTestCase() {
|
||||
val after = """
|
||||
A Discovery
|
||||
|
||||
I1 found$c it in a legendary land
|
||||
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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
assertFalse(hasSelection())
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
|
||||
class ChangeLineActionTest : VimTestCase() {
|
||||
@ -26,14 +26,14 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
setupChecks {
|
||||
this.neoVim.ignoredRegisters = setOf('1', '"')
|
||||
}
|
||||
doTest("cc", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest("cc", "", "", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun `test on empty file with S`() {
|
||||
setupChecks {
|
||||
this.neoVim.ignoredRegisters = setOf('1', '"')
|
||||
}
|
||||
doTest("S", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest("S", "", "", CommandState.Mode.INSERT, CommandState.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(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
$c
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
I found it in a legendary land
|
||||
$c
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
$c
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
$c
|
||||
all rocks and lavender and tufted grass,
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
$c
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
all rocks and lavender and tufted grass,
|
||||
$c
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
that priceless mote now dimpling the convex
|
||||
and limpid teardrop on a lighted slide.
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -20,18 +20,18 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest("cW", "foo${c}(bar baz\n", "foo baz\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-300 |c| |w|
|
||||
fun testChangeWordTwoWordsWithoutWhitespace() {
|
||||
doTest("cw", "${c}\$value\n", "value\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest("cw", "${c}\$value\n", "value\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-296 |cc|
|
||||
@ -39,7 +39,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
doTest(
|
||||
"cc",
|
||||
"foo\n" + "${c}bar\n",
|
||||
"foo\n${c}" + "\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"foo\n${c}" + "\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
....${c}
|
||||
}
|
||||
""".trimIndent().dotToSpace(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
doTest(
|
||||
"ccbaz",
|
||||
"${c}foo\n" + "bar\n",
|
||||
"baz\n" + "bar\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"baz\n" + "bar\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
${c}
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -91,23 +91,23 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
doTest(
|
||||
"c_baz",
|
||||
"${c}foo\n" + "bar\n",
|
||||
"baz\n" + "bar\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"baz\n" + "bar\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// VIM-200 |c| |w|
|
||||
fun testChangeWordAtLastChar() {
|
||||
doTest(
|
||||
"cw", "on${c}e two three\n", "on${c} two three\n", VimStateMachine.Mode.INSERT,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"cw", "on${c}e two three\n", "on${c} two three\n", CommandState.Mode.INSERT,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// VIM-1380 |c| |w| |count|
|
||||
fun testChangeTwoWordsAtLastChar() {
|
||||
doTest(
|
||||
"c2w", "on${c}e two three\n", "on${c} three\n", VimStateMachine.Mode.INSERT,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"c2w", "on${c}e two three\n", "on${c} three\n", CommandState.Mode.INSERT,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -125,15 +125,15 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// VIM-276 |c| |T|
|
||||
fun testChangeLinesTillBackwards() {
|
||||
doTest(
|
||||
"cT(", "if (condition) ${c}{\n" + "}\n", "if ({\n" + "}\n", VimStateMachine.Mode.INSERT,
|
||||
VimStateMachine.SubMode.NONE
|
||||
"cT(", "if (condition) ${c}{\n" + "}\n", "if ({\n" + "}\n", CommandState.Mode.INSERT,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
doTest(
|
||||
"cFc",
|
||||
"if (condition) {${c}\n" + "}\n",
|
||||
"if (\n" + "}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"if (\n" + "}\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
fun testChangeLastWordInLine() {
|
||||
doTest(
|
||||
"cw",
|
||||
"ab.${c}cd\n", "ab.${c}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"ab.${c}cd\n", "ab.${c}\n", CommandState.Mode.INSERT, CommandState.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", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
"foo bar bo${c}o\n", "foo bar baz\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
// VIM-421 |c| |w|
|
||||
fun testChangeLastCharInLine() {
|
||||
doTest("cw", "fo${c}o\n", "fo${c}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest("cw", "fo${c}o\n", "fo${c}\n", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun testLastSymbolInWord() {
|
||||
doTest("cw", "fo${c}o", "fo${c}", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest("cw", "fo${c}o", "fo${c}", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
}
|
||||
|
@ -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.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(
|
||||
@ -97,7 +97,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
${c}
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(description = "Wrong caret position")
|
||||
@ -145,14 +145,14 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
wh|Hello
|
||||
ha|Hello
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun `test replace first line`() {
|
||||
val keys = "VcHello<esc>"
|
||||
val before = "${c}A Discovery"
|
||||
val after = "Hello"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.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(VimStateMachine.Mode.COMMAND)
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
assertState("abcdaa${c}afffaa${c}adeaa${c}aa\n")
|
||||
}
|
||||
|
||||
@ -182,8 +182,8 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
ba_quux_bar
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -204,8 +204,8 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
ba_quux_bar
|
||||
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.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, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(
|
||||
@ -99,6 +99,6 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
|
||||
${c}
|
||||
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
doTest(keys, before, after, CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
}
|
||||
}
|
||||
|
@ -18,16 +18,16 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
|
||||
class ChangeNumberDecActionTest : VimTestCase() {
|
||||
fun `test decrement hex to negative value`() {
|
||||
doTest("<C-X>", "0x0000", "0xffffffffffffffff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("<C-X>", "0x0000", "0xffffffffffffffff", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun `test decrement hex to negative value by 10`() {
|
||||
doTest("10<C-X>", "0x0005", "0xfffffffffffffffb", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("10<C-X>", "0x0005", "0xfffffffffffffffb", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
|
||||
fun `test decrement oct to negative value`() {
|
||||
@ -35,13 +35,13 @@ class ChangeNumberDecActionTest : VimTestCase() {
|
||||
":set nrformats+=octal<CR><C-X>",
|
||||
"00000",
|
||||
"01777777777777777777777",
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
fun `test decrement incorrect octal`() {
|
||||
doTest(":set nrformats+=octal<CR><C-X>", "008", "7", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest(":set nrformats+=octal<CR><C-X>", "008", "7", CommandState.Mode.COMMAND, CommandState.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",
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,13 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
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", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
doTest("<C-A>", "1${c}0X0", "10X1", CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
|
||||
/**
|
||||
@ -38,8 +38,8 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
|
||||
number 1
|
||||
number 1
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -56,8 +56,8 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
|
||||
number 1
|
||||
number 1
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
|
||||
/**
|
||||
@ -38,8 +38,8 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
|
||||
number 3
|
||||
number 4
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
|
||||
@ -56,8 +56,8 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
|
||||
number 5
|
||||
number 7
|
||||
""".trimIndent(),
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE
|
||||
CommandState.Mode.COMMAND,
|
||||
CommandState.SubMode.NONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user