mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-02-23 23:46:03 +01:00
Migration of tests to JUnit 5
This commit is contained in:
parent
0389ea803d
commit
9271ca082c
build.gradle.kts
src/test/java/org/jetbrains/plugins/ideavim
NeovimTesting.ktRegisterActionsTest.ktTestHelper.ktVimOptionTestCase.ktVimTestCase.kt
action
AutoIndentTest.ktChangeActionTest.ktChangeNumberActionTest.ktCommandCountTest.ktCopyActionTest.ktFileGetLocationInfoActionTest.ktGuardedBlocksTest.ktMacroActionTest.ktMacroWithEditingTest.ktMarkTest.ktMotionActionTest.ktMultipleCaretsTest.ktReformatCodeTest.ktRepeatActionTest.ktResetModeActionTest.ktSpecialRegistersTest.kt
change
RepeatChangeActionTest.ktUndoActionTest.kt
change
ChangeCaseToggleCharacterActionTest.ktChangeLineActionTest.ktChangeMotionActionTest.ktChangeVisualActionTest.ktChangeVisualLinesEndActionTest.ktInsertRegisterTest.kt
number
delete
DeleteCharacterLeftActionTest.ktDeleteCharacterRightActionTest.ktDeleteEndOfLineActionTest.ktDeleteJoinLinesSpacesActionTest.ktDeleteJoinVisualLinesSpacesActionTest.ktDeleteMotionActionTest.ktDeleteVisualActionTest.ktDeleteVisualLinesActionTest.ktDeleteVisualLinesEndActionTest.ktJoinNotificationTest.kt
insert
InsertAfterCursorActionTest.ktInsertAfterLineEndActionTest.ktInsertBackspaceActionTest.ktInsertBeforeCursorActionTest.ktInsertBeforeFirstNonBlankActionTest.ktInsertCompletedLiteralActionTest.ktInsertDeleteActionTest.ktInsertDeleteInsertedTextActionTest.ktInsertDeletePreviousWordActionTest.ktInsertEnterActionTest.ktInsertExitModeActionTest.ktInsertNewLineAboveActionTest.ktInsertNewLineBelowActionTest.ktInsertSingleCommandActionTest.ktInsertTabActionTest.ktVisualBlockAppendActionTest.ktVisualBlockInsertActionTest.kt
shift
copy
IdeaPutNotificationsTest.ktPutTestAfterCursorActionTest.ktPutTextBeforeCursorActionTest.ktPutViaIdeaTest.ktPutVisualTextActionTest.ktPutVisualTextMoveCursorActionTest.ktYankAndPutTest.ktYankLineActionTest.ktYankMotionActionTest.ktYankVisualActionTest.ktYankVisualLinesActionTest.kt
motion
gn
GnNextTextObjectTest.ktGnPreviousTextObjectTest.ktVisualSelectNextSearchTest.ktVisualSelectPreviousSearchTest.kt
leftright
MotionArrowLeftActionTest.ktMotionArrowRightActionTest.ktMotionBackspaceActionTest.ktMotionEndActionTest.ktMotionHomeActionTest.ktMotionLastColumnActionTest.ktMotionLeftActionTest.ktMotionLeftInsertTest.ktMotionLeftMatchCharActionTest.ktMotionLeftTillMatchCharActionTest.ktMotionRightActionTest.ktMotionRightInsertTest.ktMotionRightMatchCharActionTest.ktMotionRightTillMatchCharActionTest.ktMotionShiftEndActionTest.ktMotionShiftHomeActionTest.ktMotionShiftLeftActionHandlerTest.ktMotionShiftRightActionHandlerTest.ktMotionSpaceActionTest.kt
mark
@ -118,6 +118,10 @@ dependencies {
|
||||
api(project(":vim-engine"))
|
||||
|
||||
testApi("com.squareup.okhttp3:okhttp:4.10.0")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.2")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.2")
|
||||
}
|
||||
|
||||
configurations {
|
||||
@ -341,6 +345,7 @@ ktlint {
|
||||
|
||||
tasks {
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
exclude("**/propertybased/**")
|
||||
exclude("**/longrunning/**")
|
||||
exclude("/ui/**")
|
||||
|
@ -14,6 +14,7 @@ import com.ensarsarajcic.neovim.java.api.types.api.VimCoords
|
||||
import com.ensarsarajcic.neovim.java.corerpc.client.ProcessRpcConnection
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.intellij.util.containers.toArray
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.CharacterPosition
|
||||
@ -29,6 +30,9 @@ import com.maddyhome.idea.vim.register.RegisterConstants.LAST_INSERTED_TEXT_REGI
|
||||
import com.maddyhome.idea.vim.register.RegisterConstants.LAST_SEARCH_REGISTER
|
||||
import com.maddyhome.idea.vim.register.RegisterConstants.VALID_REGISTERS
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
|
||||
internal object NeovimTesting {
|
||||
private lateinit var neovimApi: NeovimApi
|
||||
@ -45,7 +49,7 @@ internal object NeovimTesting {
|
||||
|
||||
private var singleCaret = true
|
||||
|
||||
fun setUp(test: VimTestCase) {
|
||||
fun setUp(test: TestInfo) {
|
||||
if (!neovimEnabled(test)) return
|
||||
val nvimPath = System.getenv("ideavim.nvim.path") ?: "nvim"
|
||||
|
||||
@ -65,10 +69,10 @@ internal object NeovimTesting {
|
||||
exitCommand = neovimApi.replaceTermcodes("<esc><esc>:qa!", true, false, true).get()
|
||||
escapeCommand = neovimApi.replaceTermcodes("<esc>", true, false, true).get()
|
||||
ctrlcCommand = neovimApi.replaceTermcodes("<C-C>", true, false, true).get()
|
||||
currentTestName = test.name
|
||||
currentTestName = test.displayName
|
||||
}
|
||||
|
||||
fun tearDown(test: VimTestCase) {
|
||||
fun tearDown(test: TestInfo) {
|
||||
if (!neovimEnabled(test)) return
|
||||
println("Tested with neovim: $neovimTestsCounter")
|
||||
if (VimTestCase.Checks.neoVim.exitOnTearDown) {
|
||||
@ -82,8 +86,8 @@ internal object NeovimTesting {
|
||||
}
|
||||
}
|
||||
|
||||
private fun neovimEnabled(test: VimTestCase, editor: Editor? = null): Boolean {
|
||||
val method = test.javaClass.getMethod(test.name)
|
||||
private fun neovimEnabled(test: TestInfo, editor: Editor? = null): Boolean {
|
||||
val method = test.testMethod.get()
|
||||
val noBehaviourDiffers = !method.isAnnotationPresent(VimBehaviorDiffers::class.java)
|
||||
val noTestingWithoutNeovim = !method.isAnnotationPresent(TestWithoutNeovim::class.java) &&
|
||||
!test.javaClass.isAnnotationPresent(TestWithoutNeovim::class.java)
|
||||
@ -103,14 +107,14 @@ internal object NeovimTesting {
|
||||
singleCaret
|
||||
}
|
||||
|
||||
fun setupEditor(editor: Editor, test: VimTestCase) {
|
||||
fun setupEditor(editor: Editor, test: TestInfo) {
|
||||
if (!neovimEnabled(test, editor)) return
|
||||
neovimApi.currentBuffer.get().setLines(0, -1, false, editor.document.text.split("\n")).get()
|
||||
val charPosition = CharacterPosition.fromOffset(editor, editor.caretModel.offset)
|
||||
neovimApi.currentWindow.get().setCursor(VimCoords(charPosition.line + 1, charPosition.column)).get()
|
||||
}
|
||||
|
||||
fun typeCommand(keys: String, test: VimTestCase, editor: Editor) {
|
||||
fun typeCommand(keys: String, test: TestInfo, editor: Editor) {
|
||||
if (!neovimEnabled(test, editor)) return
|
||||
when {
|
||||
keys.equals("<esc>", ignoreCase = true) -> neovimApi.input(escapeCommand).get()
|
||||
@ -122,7 +126,7 @@ internal object NeovimTesting {
|
||||
}
|
||||
}
|
||||
|
||||
fun assertState(editor: Editor, test: VimTestCase) {
|
||||
fun assertState(editor: Editor, test: TestInfo) {
|
||||
if (!neovimEnabled(test, editor)) return
|
||||
if (currentTestName != "") {
|
||||
currentTestName = ""
|
||||
@ -134,7 +138,7 @@ internal object NeovimTesting {
|
||||
assertRegisters()
|
||||
}
|
||||
|
||||
fun setRegister(register: Char, keys: String, test: VimTestCase) {
|
||||
fun setRegister(register: Char, keys: String, test: TestInfo) {
|
||||
if (!neovimEnabled(test)) return
|
||||
neovimApi.callFunction("setreg", listOf(register, keys, 'c'))
|
||||
}
|
||||
@ -142,7 +146,7 @@ internal object NeovimTesting {
|
||||
private fun getCaret(): VimCoords = neovimApi.currentWindow.get().cursor.get()
|
||||
private fun getText(): String = neovimApi.currentBuffer.get().getLines(0, -1, false).get().joinToString("\n")
|
||||
|
||||
fun assertCaret(editor: Editor, test: VimTestCase) {
|
||||
fun assertCaret(editor: Editor, test: TestInfo) {
|
||||
if (!neovimEnabled(test, editor)) return
|
||||
if (currentTestName != "") {
|
||||
currentTestName = ""
|
||||
@ -199,6 +203,7 @@ internal object NeovimTesting {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
annotation class TestWithoutNeovim(val reason: SkipNeovimReason, val description: String = "")
|
||||
|
||||
enum class SkipNeovimReason {
|
||||
@ -238,3 +243,18 @@ enum class SkipNeovimReason {
|
||||
fun LogicalPosition.toVimCoords(): VimCoords {
|
||||
return VimCoords(this.line + 1, this.column)
|
||||
}
|
||||
|
||||
fun <T, S, V> Collection<T>.cartesianProduct(other: Iterable<S>, transformer: (first: T, second: S) -> V): List<V> {
|
||||
return this.flatMap { first -> other.map { second -> transformer.invoke(first, second) } }
|
||||
}
|
||||
|
||||
// Cartesian product of multiple lists. Useful for making parameterized tests with all available combinations.
|
||||
// Can be used instead of @Theory from JUnit 4
|
||||
fun combinate(vararg elements: List<String>): List<Arguments> {
|
||||
val res = elements.fold(listOf<List<String>>(emptyList())) { acc, items ->
|
||||
acc.cartesianProduct(items) { accItems, item ->
|
||||
accItems + item
|
||||
}
|
||||
}
|
||||
return res.map { Arguments.of(*it.toArray(emptyArray())) }
|
||||
}
|
||||
|
@ -15,10 +15,12 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.handler.ActionBeanClass
|
||||
import com.maddyhome.idea.vim.key.CommandNode
|
||||
import com.maddyhome.idea.vim.key.CommandPartNode
|
||||
import junit.framework.TestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
import javax.swing.KeyStroke
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class RegisterActionsTest : VimTestCase() {
|
||||
@Test
|
||||
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"
|
||||
@ -26,6 +28,7 @@ class RegisterActionsTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.EDITOR_MODIFICATION)
|
||||
@Test
|
||||
fun `test action in disabled plugin`() {
|
||||
try {
|
||||
setupChecks {
|
||||
@ -42,6 +45,7 @@ class RegisterActionsTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.EDITOR_MODIFICATION)
|
||||
@Test
|
||||
fun `test turn plugin off and on`() {
|
||||
val before = "I ${c}found it in a legendary land"
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
@ -52,6 +56,7 @@ class RegisterActionsTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.EDITOR_MODIFICATION)
|
||||
@Test
|
||||
fun `test enable twice`() {
|
||||
val before = "I ${c}found it in a legendary land"
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
@ -63,6 +68,7 @@ class RegisterActionsTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.EDITOR_MODIFICATION)
|
||||
@Test
|
||||
fun `test unregister extension`() {
|
||||
val before = "I ${c}found it in a legendary land"
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
@ -71,15 +77,15 @@ class RegisterActionsTest : VimTestCase() {
|
||||
motionRightAction =
|
||||
VIM_ACTIONS_EP.getExtensionList(null).first { it.actionId == "VimPreviousTabAction" }
|
||||
|
||||
assertNotNull(getCommandNode())
|
||||
assertNotNull<Any>(getCommandNode())
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
VIM_ACTIONS_EP.getPoint(null).unregisterExtension(motionRightAction!!)
|
||||
assertNull(getCommandNode())
|
||||
kotlin.test.assertNull(getCommandNode())
|
||||
}
|
||||
@Suppress("DEPRECATION")
|
||||
VIM_ACTIONS_EP.getPoint(null).registerExtension(motionRightAction!!)
|
||||
TestCase.assertNotNull(getCommandNode())
|
||||
assertNotNull<Any>(getCommandNode())
|
||||
}
|
||||
|
||||
private fun getCommandNode(): CommandNode<*>? {
|
||||
|
@ -13,12 +13,16 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.intellij.testFramework.EditorTestUtil
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.maddyhome.idea.vim.api.getKnownToggleOption
|
||||
import com.maddyhome.idea.vim.api.globalOptions
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.api.setToggleOption
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.IjOptionConstants
|
||||
import com.maddyhome.idea.vim.helper.editorMode
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
import javax.swing.KeyStroke
|
||||
import kotlin.test.fail
|
||||
|
||||
/**
|
||||
@ -107,3 +111,39 @@ fun waitCondition(
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
internal const val c = EditorTestUtil.CARET_TAG
|
||||
internal const val s = EditorTestUtil.SELECTION_START_TAG
|
||||
internal const val se = EditorTestUtil.SELECTION_END_TAG
|
||||
|
||||
internal fun enableExtensions(vararg extensionNames: String) {
|
||||
for (name in extensionNames) {
|
||||
injector.optionGroup.setToggleOption(injector.optionGroup.getKnownToggleOption(name), OptionScope.GLOBAL)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun String.dotToTab(): String = replace('.', '\t')
|
||||
|
||||
internal fun String.dotToSpace(): String = replace('.', ' ')
|
||||
|
||||
internal fun commandToKeys(command: String): List<KeyStroke> {
|
||||
val keys: MutableList<KeyStroke> = ArrayList()
|
||||
if (!command.startsWith(":")) {
|
||||
keys.addAll(injector.parser.parseKeys(":"))
|
||||
}
|
||||
keys.addAll(injector.parser.stringToKeys(command)) // Avoids trying to parse 'command ... <args>' as a special char
|
||||
keys.addAll(injector.parser.parseKeys("<Enter>"))
|
||||
return keys
|
||||
}
|
||||
|
||||
internal fun exCommand(command: String) = ":$command<CR>"
|
||||
|
||||
internal fun searchToKeys(pattern: String, forwards: Boolean): List<KeyStroke> {
|
||||
val keys: MutableList<KeyStroke> = ArrayList()
|
||||
keys.addAll(injector.parser.parseKeys(if (forwards) "/" else "?"))
|
||||
keys.addAll(injector.parser.stringToKeys(pattern)) // Avoids trying to parse 'command ... <args>' as a special char
|
||||
keys.addAll(injector.parser.parseKeys("<CR>"))
|
||||
return keys
|
||||
}
|
||||
|
||||
internal fun searchCommand(pattern: String) = "$pattern<CR>"
|
||||
|
@ -13,6 +13,8 @@ import com.maddyhome.idea.vim.ex.exExceptionMessage
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
@ -33,9 +35,10 @@ import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||
abstract class VimOptionTestCase(option: String, vararg otherOptions: String) : VimTestCase() {
|
||||
private val options: Set<String> = setOf(option, *otherOptions)
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
val testMethod = this.javaClass.getMethod(this.name)
|
||||
@BeforeEach
|
||||
override fun setUp(testInfo: TestInfo) {
|
||||
super.setUp(testInfo)
|
||||
val testMethod = this.testInfo.testMethod.get()
|
||||
if (!testMethod.isAnnotationPresent(VimOptionDefaultAll::class.java)) {
|
||||
if (!testMethod.isAnnotationPresent(VimOptionTestConfiguration::class.java)) kotlin.test.fail("You should add VimOptionTestConfiguration with options for this method")
|
||||
|
||||
|
@ -31,10 +31,10 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.testFramework.EditorTestUtil
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl
|
||||
import com.intellij.testFramework.junit5.RunInEdt
|
||||
import com.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.action.VimShortcutKeyAction
|
||||
@ -76,33 +76,48 @@ import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimFuncref
|
||||
import com.maddyhome.idea.vim.vimscript.parser.errors.IdeavimErrorListener
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.Assert
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import java.awt.event.KeyEvent
|
||||
import java.util.*
|
||||
import javax.swing.KeyStroke
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
* JUnit 5 tests
|
||||
*
|
||||
* To plugin writers: this class is internal, thus not allowed to be used by third-party plugins.
|
||||
* This is done as we have no mechanism to guarantee compatibility as we update this test case.
|
||||
* Feel free to copy this class into your plugin, or copy just needed functions.
|
||||
*/
|
||||
abstract class VimTestCase : UsefulTestCase() {
|
||||
protected lateinit var myFixture: CodeInsightTestFixture
|
||||
@RunInEdt
|
||||
@ApiStatus.Internal
|
||||
abstract class VimTestCase {
|
||||
protected lateinit var fixture: CodeInsightTestFixture
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
internal lateinit var testInfo: TestInfo
|
||||
|
||||
@BeforeEach
|
||||
open fun setUp(testInfo: TestInfo) {
|
||||
val factory = IdeaTestFixtureFactory.getFixtureFactory()
|
||||
val projectDescriptor = LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR
|
||||
val fixtureBuilder = factory.createLightFixtureBuilder(projectDescriptor, "IdeaVim")
|
||||
val fixture = fixtureBuilder.fixture
|
||||
myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(
|
||||
this.fixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(
|
||||
fixture,
|
||||
LightTempDirTestFixtureImpl(true),
|
||||
)
|
||||
myFixture.setUp()
|
||||
myFixture.testDataPath = testDataPath
|
||||
this.fixture.setUp()
|
||||
this.fixture.testDataPath = testDataPath
|
||||
// Note that myFixture.editor is usually null here. It's only set once configureByText has been called
|
||||
val editor = myFixture.editor
|
||||
val editor = this.fixture.editor
|
||||
if (editor != null) {
|
||||
KeyHandler.getInstance().fullReset(editor.vim)
|
||||
}
|
||||
@ -119,9 +134,11 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
// Make sure the entry text field gets a bounds, or we won't be able to work out caret location
|
||||
ExEntryPanel.getInstance().entry.setBounds(0, 0, 100, 25)
|
||||
|
||||
NeovimTesting.setUp(this)
|
||||
NeovimTesting.setUp(testInfo)
|
||||
|
||||
VimPlugin.clearError()
|
||||
|
||||
this.testInfo = testInfo
|
||||
}
|
||||
|
||||
// Hook for setting up the editor
|
||||
@ -130,15 +147,15 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
private val testDataPath: String
|
||||
get() = PathManager.getHomePath() + "/community/plugins/ideavim/testData"
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun tearDown() {
|
||||
@AfterEach
|
||||
open fun tearDown() {
|
||||
val swingTimer = swingTimer
|
||||
swingTimer?.stop()
|
||||
val bookmarksManager = BookmarksManager.getInstance(myFixture.project)
|
||||
val bookmarksManager = BookmarksManager.getInstance(fixture.project)
|
||||
bookmarksManager?.bookmarks?.forEach { bookmark ->
|
||||
bookmarksManager.remove(bookmark)
|
||||
}
|
||||
SelectionVimListenerSuppressor.lock().use { myFixture.tearDown() }
|
||||
SelectionVimListenerSuppressor.lock().use { fixture.tearDown() }
|
||||
ExEntryPanel.getInstance().deactivate(false)
|
||||
VimPlugin.getVariableService().clear()
|
||||
VimFuncref.lambdaCounter = 0
|
||||
@ -152,9 +169,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
VimPlugin.getKey().savedShortcutConflicts.clear()
|
||||
|
||||
// Tear down neovim
|
||||
NeovimTesting.tearDown(this)
|
||||
|
||||
super.tearDown()
|
||||
NeovimTesting.tearDown(testInfo)
|
||||
}
|
||||
|
||||
protected fun enableExtensions(vararg extensionNames: String) {
|
||||
@ -163,6 +178,10 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
protected fun <T> assertEmpty(collection: Collection<T>) {
|
||||
assertTrue(collection.isEmpty(), "Collection should be empty, but it contains ${collection.size} elements")
|
||||
}
|
||||
|
||||
protected fun typeTextInFile(keys: List<KeyStroke?>, fileContents: String): Editor {
|
||||
configureByText(fileContents)
|
||||
return typeText(keys)
|
||||
@ -179,34 +198,35 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
get() = 35
|
||||
|
||||
protected fun setEditorVisibleSize(width: Int, height: Int) {
|
||||
val w = (width * EditorHelper.getPlainSpaceWidthFloat(myFixture.editor)).roundToInt()
|
||||
val h = height * myFixture.editor.lineHeight
|
||||
EditorTestUtil.setEditorVisibleSizeInPixels(myFixture.editor, w, h)
|
||||
val w = (width * EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
val h = height * fixture.editor.lineHeight
|
||||
EditorTestUtil.setEditorVisibleSizeInPixels(fixture.editor, w, h)
|
||||
}
|
||||
|
||||
protected fun setEditorVirtualSpace() {
|
||||
// Enable virtual space at the bottom of the file and force a layout to pick up the changes
|
||||
myFixture.editor.settings.isAdditionalPageAtBottom = true
|
||||
(myFixture.editor as EditorEx).scrollPane.viewport.doLayout()
|
||||
fixture.editor.settings.isAdditionalPageAtBottom = true
|
||||
(fixture.editor as EditorEx).scrollPane.viewport.doLayout()
|
||||
}
|
||||
|
||||
protected fun configureByText(content: String) = configureByText(PlainTextFileType.INSTANCE, content)
|
||||
protected fun configureByJavaText(content: String) = configureByText(JavaFileType.INSTANCE, content)
|
||||
protected fun configureByXmlText(content: String) = configureByText(XmlFileType.INSTANCE, content)
|
||||
protected fun configureByJsonText(@Suppress("SameParameterValue") content: String) = configureByText(JsonFileType.INSTANCE, content)
|
||||
protected fun configureByJsonText(@Suppress("SameParameterValue") content: String) =
|
||||
configureByText(JsonFileType.INSTANCE, content)
|
||||
|
||||
protected fun configureAndGuard(content: String) {
|
||||
val ranges = extractBrackets(content)
|
||||
for ((start, end) in ranges) {
|
||||
myFixture.editor.document.createGuardedBlock(start, end)
|
||||
fixture.editor.document.createGuardedBlock(start, end)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun configureAndFold(content: String, @Suppress("SameParameterValue") placeholder: String) {
|
||||
val ranges = extractBrackets(content)
|
||||
myFixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
fixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
for ((start, end) in ranges) {
|
||||
val foldRegion = myFixture.editor.foldingModel.addFoldRegion(start, end, placeholder)
|
||||
val foldRegion = fixture.editor.foldingModel.addFoldRegion(start, end, placeholder)
|
||||
foldRegion?.isExpanded = false
|
||||
}
|
||||
}
|
||||
@ -229,30 +249,27 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
|
||||
private fun configureByText(fileType: FileType, content: String): Editor {
|
||||
@Suppress("IdeaVimAssertState")
|
||||
myFixture.configureByText(fileType, content)
|
||||
NeovimTesting.setupEditor(myFixture.editor, this)
|
||||
fixture.configureByText(fileType, content)
|
||||
NeovimTesting.setupEditor(fixture.editor, testInfo)
|
||||
setEditorVisibleSize(screenWidth, screenHeight)
|
||||
setupEditor()
|
||||
return myFixture.editor
|
||||
return fixture.editor
|
||||
}
|
||||
|
||||
private fun configureByText(fileName: String, content: String): Editor {
|
||||
@Suppress("IdeaVimAssertState")
|
||||
myFixture.configureByText(fileName, content)
|
||||
NeovimTesting.setupEditor(myFixture.editor, this)
|
||||
fixture.configureByText(fileName, content)
|
||||
NeovimTesting.setupEditor(fixture.editor, testInfo)
|
||||
setEditorVisibleSize(screenWidth, screenHeight)
|
||||
setupEditor()
|
||||
return myFixture.editor
|
||||
return fixture.editor
|
||||
}
|
||||
|
||||
protected fun configureByFileName(fileName: String): Editor {
|
||||
@Suppress("IdeaVimAssertState")
|
||||
myFixture.configureByText(fileName, "\n")
|
||||
NeovimTesting.setupEditor(myFixture.editor, this)
|
||||
fixture.configureByText(fileName, "\n")
|
||||
NeovimTesting.setupEditor(fixture.editor, testInfo)
|
||||
setEditorVisibleSize(screenWidth, screenHeight)
|
||||
setupEditor()
|
||||
return myFixture.editor
|
||||
return fixture.editor
|
||||
}
|
||||
|
||||
@Suppress("SameParameterValue")
|
||||
@ -304,23 +321,23 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
assertPosition(caretLogicalLine, caretLogicalColumn)
|
||||
|
||||
// Belt and braces. Let's make sure that the caret is fully onscreen
|
||||
val bottomLogicalLine = myFixture.editor.vim.visualLineToBufferLine(
|
||||
EditorHelper.getVisualLineAtBottomOfScreen(myFixture.editor),
|
||||
val bottomLogicalLine = fixture.editor.vim.visualLineToBufferLine(
|
||||
EditorHelper.getVisualLineAtBottomOfScreen(fixture.editor),
|
||||
)
|
||||
assertTrue(bottomLogicalLine >= caretLogicalLine)
|
||||
assertTrue(caretLogicalLine >= scrollToLogicalLine)
|
||||
kotlin.test.assertTrue(bottomLogicalLine >= caretLogicalLine)
|
||||
kotlin.test.assertTrue(caretLogicalLine >= scrollToLogicalLine)
|
||||
}
|
||||
|
||||
protected fun typeText(vararg keys: String) = typeText(keys.flatMap { injector.parser.parseKeys(it) })
|
||||
|
||||
protected fun typeText(keys: List<KeyStroke?>): Editor {
|
||||
val editor = myFixture.editor
|
||||
val editor = fixture.editor
|
||||
NeovimTesting.typeCommand(
|
||||
keys.filterNotNull().joinToString(separator = "") { injector.parser.toKeyNotation(it) },
|
||||
this,
|
||||
testInfo,
|
||||
editor,
|
||||
)
|
||||
val project = myFixture.project
|
||||
val project = fixture.project
|
||||
when (Checks.keyHandler) {
|
||||
Checks.KeyHandlerMethod.DIRECT_TO_VIM -> typeText(keys.filterNotNull(), editor, project)
|
||||
Checks.KeyHandlerMethod.VIA_IDE -> typeTextViaIde(keys.filterNotNull(), editor)
|
||||
@ -338,7 +355,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
|
||||
protected fun setText(text: String) {
|
||||
WriteAction.runAndWait<RuntimeException> {
|
||||
myFixture.editor.document.setText(text)
|
||||
fixture.editor.document.setText(text)
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,10 +369,10 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
*/
|
||||
protected fun options(): OptionValueAccessor {
|
||||
assertNotNull(
|
||||
fixture.editor,
|
||||
"Editor is null! Move the call to after editor is initialised, or use optionsNoEditor",
|
||||
myFixture.editor,
|
||||
)
|
||||
return injector.options(myFixture.editor.vim)
|
||||
return injector.options(fixture.editor.vim)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,14 +386,13 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
* before the editor has been initialised.
|
||||
*/
|
||||
protected fun optionsNoEditor(): OptionValueAccessor {
|
||||
assertNull("Editor is not null! Use options() to access effective option values", myFixture.editor)
|
||||
assertNull(fixture.editor, "Editor is not null! Use options() to access effective option values")
|
||||
return injector.globalOptions()
|
||||
}
|
||||
|
||||
fun assertState(textAfter: String) {
|
||||
@Suppress("IdeaVimAssertState")
|
||||
myFixture.checkResult(textAfter)
|
||||
NeovimTesting.assertState(myFixture.editor, this)
|
||||
fixture.checkResult(textAfter)
|
||||
NeovimTesting.assertState(fixture.editor, testInfo)
|
||||
}
|
||||
|
||||
protected fun assertState(modeAfter: VimStateMachine.Mode, subModeAfter: SubMode) {
|
||||
@ -386,39 +402,39 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
|
||||
fun assertPosition(line: Int, column: Int) {
|
||||
val carets = myFixture.editor.caretModel.allCarets
|
||||
Assert.assertEquals("Wrong amount of carets", 1, carets.size)
|
||||
val carets = fixture.editor.caretModel.allCarets
|
||||
assertEquals(1, carets.size, "Wrong amount of carets")
|
||||
val actualPosition = carets[0].logicalPosition
|
||||
Assert.assertEquals(LogicalPosition(line, column), actualPosition)
|
||||
NeovimTesting.assertCaret(myFixture.editor, this)
|
||||
kotlin.test.assertEquals(LogicalPosition(line, column), actualPosition)
|
||||
NeovimTesting.assertCaret(fixture.editor, testInfo)
|
||||
}
|
||||
|
||||
fun assertVisualPosition(visualLine: Int, visualColumn: Int) {
|
||||
val carets = myFixture.editor.caretModel.allCarets
|
||||
Assert.assertEquals("Wrong amount of carets", 1, carets.size)
|
||||
val carets = fixture.editor.caretModel.allCarets
|
||||
assertEquals(1, carets.size, "Wrong amount of carets")
|
||||
val actualPosition = carets[0].visualPosition
|
||||
Assert.assertEquals(VisualPosition(visualLine, visualColumn), actualPosition)
|
||||
kotlin.test.assertEquals(VisualPosition(visualLine, visualColumn), actualPosition)
|
||||
}
|
||||
|
||||
fun assertOffset(vararg expectedOffsets: Int) {
|
||||
val carets = myFixture.editor.caretModel.allCarets
|
||||
val carets = fixture.editor.caretModel.allCarets
|
||||
if (expectedOffsets.size == 2 && carets.size == 1) {
|
||||
Assert.assertEquals(
|
||||
"Wrong amount of carets. Did you mean to use assertPosition?",
|
||||
assertEquals(
|
||||
expectedOffsets.size,
|
||||
carets.size,
|
||||
"Wrong amount of carets. Did you mean to use assertPosition?",
|
||||
)
|
||||
}
|
||||
Assert.assertEquals("Wrong amount of carets", expectedOffsets.size, carets.size)
|
||||
assertEquals(expectedOffsets.size, carets.size, "Wrong amount of carets")
|
||||
for (i in expectedOffsets.indices) {
|
||||
Assert.assertEquals(expectedOffsets[i], carets[i].offset)
|
||||
kotlin.test.assertEquals(expectedOffsets[i], carets[i].offset)
|
||||
}
|
||||
|
||||
NeovimTesting.assertState(myFixture.editor, this)
|
||||
NeovimTesting.assertState(fixture.editor, testInfo)
|
||||
}
|
||||
|
||||
fun assertOffsetAt(text: String) {
|
||||
val indexOf = myFixture.editor.document.charsSequence.indexOf(text)
|
||||
val indexOf = fixture.editor.document.charsSequence.indexOf(text)
|
||||
if (indexOf < 0) kotlin.test.fail()
|
||||
assertOffset(indexOf)
|
||||
}
|
||||
@ -430,52 +446,58 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
|
||||
fun assertTopLogicalLine(topLogicalLine: Int) {
|
||||
val actualVisualTop = EditorHelper.getVisualLineAtTopOfScreen(myFixture.editor)
|
||||
val actualLogicalTop = myFixture.editor.vim.visualLineToBufferLine(actualVisualTop)
|
||||
val actualVisualTop = EditorHelper.getVisualLineAtTopOfScreen(fixture.editor)
|
||||
val actualLogicalTop = fixture.editor.vim.visualLineToBufferLine(actualVisualTop)
|
||||
|
||||
Assert.assertEquals("Top logical lines don't match", topLogicalLine, actualLogicalTop)
|
||||
assertEquals(topLogicalLine, actualLogicalTop, "Top logical lines don't match")
|
||||
}
|
||||
|
||||
fun assertBottomLogicalLine(bottomLogicalLine: Int) {
|
||||
val actualVisualBottom = EditorHelper.getVisualLineAtBottomOfScreen(myFixture.editor)
|
||||
val actualLogicalBottom = myFixture.editor.vim.visualLineToBufferLine(actualVisualBottom)
|
||||
val actualVisualBottom = EditorHelper.getVisualLineAtBottomOfScreen(fixture.editor)
|
||||
val actualLogicalBottom = fixture.editor.vim.visualLineToBufferLine(actualVisualBottom)
|
||||
|
||||
Assert.assertEquals("Bottom logical lines don't match", bottomLogicalLine, actualLogicalBottom)
|
||||
assertEquals(bottomLogicalLine, actualLogicalBottom, "Bottom logical lines don't match")
|
||||
}
|
||||
|
||||
fun assertVisibleLineBounds(logicalLine: Int, leftLogicalColumn: Int, rightLogicalColumn: Int) {
|
||||
val visualLine = IjVimEditor(myFixture.editor).bufferLineToVisualLine(logicalLine)
|
||||
val actualLeftVisualColumn = EditorHelper.getVisualColumnAtLeftOfDisplay(myFixture.editor, visualLine)
|
||||
val visualLine = IjVimEditor(fixture.editor).bufferLineToVisualLine(logicalLine)
|
||||
val actualLeftVisualColumn = EditorHelper.getVisualColumnAtLeftOfDisplay(fixture.editor, visualLine)
|
||||
val actualLeftLogicalColumn =
|
||||
myFixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualLeftVisualColumn)).column
|
||||
val actualRightVisualColumn = EditorHelper.getVisualColumnAtRightOfDisplay(myFixture.editor, visualLine)
|
||||
fixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualLeftVisualColumn)).column
|
||||
val actualRightVisualColumn = EditorHelper.getVisualColumnAtRightOfDisplay(fixture.editor, visualLine)
|
||||
val actualRightLogicalColumn =
|
||||
myFixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualRightVisualColumn)).column
|
||||
fixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualRightVisualColumn)).column
|
||||
|
||||
val expected = ScreenBounds(leftLogicalColumn, rightLogicalColumn)
|
||||
val actual = ScreenBounds(actualLeftLogicalColumn, actualRightLogicalColumn)
|
||||
Assert.assertEquals(expected, actual)
|
||||
kotlin.test.assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
fun assertLineCount(expected: Int) {
|
||||
assertEquals(expected, myFixture.editor.vim.lineCount())
|
||||
kotlin.test.assertEquals(expected, fixture.editor.vim.lineCount())
|
||||
}
|
||||
|
||||
fun putMapping(modes: Set<MappingMode>, from: String, to: String, recursive: Boolean) {
|
||||
VimPlugin.getKey().putKeyMapping(modes, injector.parser.parseKeys(from), MappingOwner.IdeaVim.System, injector.parser.parseKeys(to), recursive)
|
||||
VimPlugin.getKey().putKeyMapping(
|
||||
modes,
|
||||
injector.parser.parseKeys(from),
|
||||
MappingOwner.IdeaVim.System,
|
||||
injector.parser.parseKeys(to),
|
||||
recursive
|
||||
)
|
||||
}
|
||||
|
||||
fun assertNoMapping(from: String) {
|
||||
val keys = injector.parser.parseKeys(from)
|
||||
for (mode in MappingMode.ALL) {
|
||||
assertNull(VimPlugin.getKey().getKeyMapping(mode)[keys])
|
||||
kotlin.test.assertNull(VimPlugin.getKey().getKeyMapping(mode)[keys])
|
||||
}
|
||||
}
|
||||
|
||||
fun assertNoMapping(from: String, modes: Set<MappingMode>) {
|
||||
val keys = injector.parser.parseKeys(from)
|
||||
for (mode in modes) {
|
||||
assertNull(VimPlugin.getKey().getKeyMapping(mode)[keys])
|
||||
kotlin.test.assertNull(VimPlugin.getKey().getKeyMapping(mode)[keys])
|
||||
}
|
||||
}
|
||||
|
||||
@ -484,9 +506,9 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
val toKeys = injector.parser.parseKeys(to)
|
||||
for (mode in modes) {
|
||||
val info = VimPlugin.getKey().getKeyMapping(mode)[keys]
|
||||
kotlin.test.assertNotNull(info)
|
||||
assertNotNull<Any>(info)
|
||||
if (info is ToKeysMappingInfo) {
|
||||
assertEquals(toKeys, info.toKeys)
|
||||
kotlin.test.assertEquals(toKeys, info.toKeys)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -498,34 +520,34 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
|
||||
fun assertMode(expectedMode: VimStateMachine.Mode) {
|
||||
val mode = myFixture.editor.editorMode
|
||||
Assert.assertEquals(expectedMode, mode)
|
||||
val mode = fixture.editor.editorMode
|
||||
kotlin.test.assertEquals(expectedMode, mode)
|
||||
}
|
||||
|
||||
fun assertSubMode(expectedSubMode: SubMode) {
|
||||
val subMode = myFixture.editor.subMode
|
||||
Assert.assertEquals(expectedSubMode, subMode)
|
||||
val subMode = fixture.editor.subMode
|
||||
kotlin.test.assertEquals(expectedSubMode, subMode)
|
||||
}
|
||||
|
||||
fun assertSelection(expected: String?) {
|
||||
val selected = myFixture.editor.selectionModel.selectedText
|
||||
Assert.assertEquals(expected, selected)
|
||||
val selected = fixture.editor.selectionModel.selectedText
|
||||
kotlin.test.assertEquals(expected, selected)
|
||||
}
|
||||
|
||||
fun assertExOutput(expected: String) {
|
||||
val actual = getInstance(myFixture.editor).text
|
||||
Assert.assertNotNull("No Ex output", actual)
|
||||
Assert.assertEquals(expected, actual)
|
||||
NeovimTesting.typeCommand("<esc>", this, myFixture.editor)
|
||||
val actual = getInstance(fixture.editor).text
|
||||
assertNotNull("No Ex output", actual)
|
||||
kotlin.test.assertEquals(expected, actual)
|
||||
NeovimTesting.typeCommand("<esc>", testInfo, fixture.editor)
|
||||
}
|
||||
|
||||
fun assertNoExOutput() {
|
||||
val actual = getInstance(myFixture.editor).text
|
||||
Assert.assertNull("Ex output not null", actual)
|
||||
val actual = getInstance(fixture.editor).text
|
||||
assertNull(actual, "Ex output not null")
|
||||
}
|
||||
|
||||
fun assertPluginError(isError: Boolean) {
|
||||
Assert.assertEquals(isError, injector.messages.isError())
|
||||
kotlin.test.assertEquals(isError, injector.messages.isError())
|
||||
}
|
||||
|
||||
fun assertPluginErrorMessageContains(message: String) {
|
||||
@ -534,25 +556,28 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
|
||||
protected fun assertCaretsVisualAttributes() {
|
||||
if (!Checks.caretShape) return
|
||||
val editor = myFixture.editor
|
||||
val editor = fixture.editor
|
||||
val attributes = GuiCursorOptionHelper.getAttributes(getGuiCursorMode(editor))
|
||||
val colour = editor.colorsScheme.getColor(EditorColors.CARET_COLOR)
|
||||
|
||||
editor.caretModel.allCarets.forEach { caret ->
|
||||
// All carets should be the same except when in block sub mode, where we "hide" them (by drawing a zero width bar)
|
||||
if (caret !== editor.caretModel.primaryCaret && editor.inBlockSubMode) {
|
||||
assertEquals(CaretVisualAttributes.Shape.BAR, caret.visualAttributes.shape)
|
||||
assertEquals(0F, caret.visualAttributes.thickness)
|
||||
kotlin.test.assertEquals(CaretVisualAttributes.Shape.BAR, caret.visualAttributes.shape)
|
||||
kotlin.test.assertEquals(0F, caret.visualAttributes.thickness)
|
||||
} else {
|
||||
val shape = when (attributes.type) {
|
||||
GuiCursorType.BLOCK -> CaretVisualAttributes.Shape.BLOCK
|
||||
GuiCursorType.VER -> CaretVisualAttributes.Shape.BAR
|
||||
GuiCursorType.HOR -> CaretVisualAttributes.Shape.UNDERSCORE
|
||||
}
|
||||
assertEquals(shape, editor.caretModel.primaryCaret.visualAttributes.shape)
|
||||
assertEquals(attributes.thickness / 100.0F, editor.caretModel.primaryCaret.visualAttributes.thickness)
|
||||
kotlin.test.assertEquals(shape, editor.caretModel.primaryCaret.visualAttributes.shape)
|
||||
kotlin.test.assertEquals(
|
||||
attributes.thickness / 100.0F,
|
||||
editor.caretModel.primaryCaret.visualAttributes.thickness
|
||||
)
|
||||
editor.caretModel.primaryCaret.visualAttributes.color?.let {
|
||||
assertEquals(colour, it)
|
||||
kotlin.test.assertEquals(colour, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -569,7 +594,16 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
fileName: String? = null,
|
||||
afterEditorInitialized: ((Editor) -> Unit)? = null,
|
||||
) {
|
||||
doTest(keys.joinToString(separator = ""), before, after, modeAfter, subModeAfter, fileType, fileName, afterEditorInitialized)
|
||||
doTest(
|
||||
keys.joinToString(separator = ""),
|
||||
before,
|
||||
after,
|
||||
modeAfter,
|
||||
subModeAfter,
|
||||
fileType,
|
||||
fileName,
|
||||
afterEditorInitialized
|
||||
)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@ -590,7 +624,7 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
} else {
|
||||
configureByText(before)
|
||||
}
|
||||
afterEditorInitialized?.invoke(myFixture.editor)
|
||||
afterEditorInitialized?.invoke(fixture.editor)
|
||||
performTest(keys, after, modeAfter, subModeAfter)
|
||||
}
|
||||
|
||||
@ -603,29 +637,37 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
|
||||
protected fun setRegister(register: Char, keys: String) {
|
||||
VimPlugin.getRegister().setKeys(register, injector.parser.stringToKeys(keys))
|
||||
NeovimTesting.setRegister(register, keys, this)
|
||||
NeovimTesting.setRegister(register, keys, testInfo)
|
||||
}
|
||||
|
||||
protected val fileManager: FileEditorManagerEx
|
||||
get() = FileEditorManagerEx.getInstanceEx(myFixture.project)
|
||||
get() = FileEditorManagerEx.getInstanceEx(fixture.project)
|
||||
|
||||
// Specify width in columns, not pixels, just like we do for visible screen size. The default text char width differs
|
||||
// per platform (e.g. Windows is 7, Mac is 8) so we can't guarantee correct positioning for tests if we use hard coded
|
||||
// pixel widths
|
||||
protected fun addInlay(offset: Int, relatesToPrecedingText: Boolean, @Suppress("SameParameterValue") widthInColumns: Int): Inlay<*> {
|
||||
val widthInPixels = (EditorHelper.getPlainSpaceWidthFloat(myFixture.editor) * widthInColumns).roundToInt()
|
||||
return EditorTestUtil.addInlay(myFixture.editor, offset, relatesToPrecedingText, widthInPixels)
|
||||
protected fun addInlay(
|
||||
offset: Int,
|
||||
relatesToPrecedingText: Boolean,
|
||||
@Suppress("SameParameterValue") widthInColumns: Int
|
||||
): Inlay<*> {
|
||||
val widthInPixels = (EditorHelper.getPlainSpaceWidthFloat(fixture.editor) * widthInColumns).roundToInt()
|
||||
return EditorTestUtil.addInlay(fixture.editor, offset, relatesToPrecedingText, widthInPixels)
|
||||
}
|
||||
|
||||
// As for inline inlays, height is specified as a multiplier of line height, as we can't guarantee the same line
|
||||
// height on all platforms, so can't guarantee correct positioning for tests if we use pixels. This currently limits
|
||||
// us to integer multiples of line heights. I don't think this will cause any issues, but we can change this to a
|
||||
// float if necessary. We'd still be working scaled to the line height, so fractional values should still work.
|
||||
protected fun addBlockInlay(offset: Int, @Suppress("SameParameterValue") showAbove: Boolean, heightInRows: Int): Inlay<*> {
|
||||
protected fun addBlockInlay(
|
||||
offset: Int,
|
||||
@Suppress("SameParameterValue") showAbove: Boolean,
|
||||
heightInRows: Int
|
||||
): Inlay<*> {
|
||||
val widthInColumns = 10 // Arbitrary width. We don't care.
|
||||
val widthInPixels = (EditorHelper.getPlainSpaceWidthFloat(myFixture.editor) * widthInColumns).roundToInt()
|
||||
val heightInPixels = myFixture.editor.lineHeight * heightInRows
|
||||
return EditorTestUtil.addBlockInlay(myFixture.editor, offset, false, showAbove, widthInPixels, heightInPixels)
|
||||
val widthInPixels = (EditorHelper.getPlainSpaceWidthFloat(fixture.editor) * widthInColumns).roundToInt()
|
||||
val heightInPixels = fixture.editor.lineHeight * heightInRows
|
||||
return EditorTestUtil.addBlockInlay(fixture.editor, offset, false, showAbove, widthInPixels, heightInPixels)
|
||||
}
|
||||
|
||||
// Disable or enable checks for the particular test
|
||||
@ -634,7 +676,10 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
}
|
||||
|
||||
protected fun assertExException(expectedErrorMessage: String, action: () -> Unit) {
|
||||
assertThrows(ExException::class.java, expectedErrorMessage, action)
|
||||
val exception = assertThrows<ExException> {
|
||||
action()
|
||||
}
|
||||
kotlin.test.assertEquals(expectedErrorMessage, exception.message)
|
||||
}
|
||||
|
||||
private fun typeTextViaIde(keys: List<KeyStroke?>, editor: Editor) {
|
||||
@ -646,12 +691,14 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
val keyChar = key.getChar(editor)
|
||||
when (keyChar) {
|
||||
is CharType.CharDetected -> {
|
||||
myFixture.type(keyChar.char)
|
||||
fixture.type(keyChar.char)
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
}
|
||||
|
||||
is CharType.EditorAction -> {
|
||||
myFixture.performEditorAction(keyChar.name)
|
||||
fixture.performEditorAction(keyChar.name)
|
||||
}
|
||||
|
||||
CharType.UNDEFINED -> {
|
||||
val event =
|
||||
KeyEvent(editor.component, KeyEvent.KEY_PRESSED, Date().time, key.modifiers, key.keyCode, key.keyChar)
|
||||
|
@ -11,10 +11,12 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class AutoIndentTest : VimTestCase() {
|
||||
// VIM-256 |==|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testCaretPositionAfterAutoIndent() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
@ -37,6 +39,7 @@ class AutoIndentTest : VimTestCase() {
|
||||
|
||||
// |2==|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testAutoIndentWithCount() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
@ -61,6 +64,7 @@ class AutoIndentTest : VimTestCase() {
|
||||
|
||||
// |=k|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testAutoIndentWithUpMotion() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
@ -85,6 +89,7 @@ class AutoIndentTest : VimTestCase() {
|
||||
|
||||
// |=l|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testAutoIndentWithRightMotion() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
@ -107,6 +112,7 @@ class AutoIndentTest : VimTestCase() {
|
||||
|
||||
// |2=j|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testAutoIndentWithCountsAndDownMotion() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
@ -131,6 +137,7 @@ class AutoIndentTest : VimTestCase() {
|
||||
|
||||
// |v| |l| |=|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testVisualAutoIndent() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
@ -153,6 +160,7 @@ class AutoIndentTest : VimTestCase() {
|
||||
|
||||
// |v| |j| |=|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testVisualMultilineAutoIndent() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
@ -177,6 +185,7 @@ class AutoIndentTest : VimTestCase() {
|
||||
|
||||
// |C-v| |j| |=|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testVisualBlockAutoIndent() {
|
||||
configureByJavaText(
|
||||
"""class C {
|
||||
|
@ -15,12 +15,15 @@ import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
class ChangeActionTest : VimTestCase() {
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@Test
|
||||
fun testInsertSingleCommandAndInserting() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"),
|
||||
@ -32,6 +35,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@Test
|
||||
fun testInsertSingleCommandAndNewLineInserting() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "o", "123", "<Esc>", "x"),
|
||||
@ -43,6 +47,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@Test
|
||||
fun testInsertSingleCommandAndNewLineInserting2() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "v"),
|
||||
@ -54,6 +59,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@Test
|
||||
fun testInsertSingleCommandAndNewLineInserting3() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "v", "<esc>"),
|
||||
@ -65,6 +71,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@Test
|
||||
fun testInsertSingleCommandAndNewLineInserting4() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "v", "d"),
|
||||
@ -77,6 +84,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@TestWithoutNeovim(SkipNeovimReason.SELECT_MODE)
|
||||
@Test
|
||||
fun testInsertSingleCommandAndNewLineInserting5() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "v", "<C-G>"),
|
||||
@ -89,6 +97,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@TestWithoutNeovim(SkipNeovimReason.SELECT_MODE)
|
||||
@Test
|
||||
fun testInsertSingleCommandAndNewLineInserting6() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "gh"),
|
||||
@ -101,6 +110,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
|
||||
// VIM-620 |i_CTRL-O|
|
||||
@TestWithoutNeovim(SkipNeovimReason.SELECT_MODE)
|
||||
@Test
|
||||
fun testInsertSingleCommandAndNewLineInserting7() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "gh", "<esc>"),
|
||||
@ -111,18 +121,19 @@ class ChangeActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
// Turn it on after typing via handlers are implemented for tests
|
||||
// VIM-620 |i_CTRL-O|
|
||||
fun ignoreTestInsertSingleCommandAndNewLineInserting8() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testInsertSingleCommandAndNewLineInserting8() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "gh", "d"),
|
||||
"12${c}345", "12d${c}45", CommandState.Mode.INSERT, CommandState.SubMode.NONE
|
||||
"12${c}345", "12d${c}45", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
|
||||
)
|
||||
}
|
||||
*/
|
||||
|
||||
// VIM-311 |i_CTRL-O|
|
||||
@Test
|
||||
fun testInsertSingleCommand() {
|
||||
doTest(
|
||||
listOf("i", "def", "<C-O>", "d2h", "x"),
|
||||
@ -134,24 +145,29 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-321 |d| |count|
|
||||
@Test
|
||||
fun testDeleteEmptyRange() {
|
||||
doTest("d0", "${c}hello\n", "hello\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-157 |~|
|
||||
@Test
|
||||
fun testToggleCharCase() {
|
||||
doTest("~~", "${c}hello world\n", "HEllo world\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-157 |~|
|
||||
@Test
|
||||
fun testToggleCharCaseLineEnd() {
|
||||
doTest("~~", "hello wor${c}ld\n", "hello worLD\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testToggleCaseMotion() {
|
||||
doTest("g~w", "${c}FooBar Baz\n", "fOObAR Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeUpperCase() {
|
||||
doTest(
|
||||
"gUw",
|
||||
@ -162,10 +178,12 @@ class ChangeActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeLowerCase() {
|
||||
doTest("guw", "${c}FooBar Baz\n", "foobar Baz\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testToggleCaseVisual() {
|
||||
doTest(
|
||||
"ve~",
|
||||
@ -176,6 +194,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeUpperCaseVisual() {
|
||||
doTest(
|
||||
"veU",
|
||||
@ -186,6 +205,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeLowerCaseVisual() {
|
||||
doTest(
|
||||
"veu",
|
||||
@ -197,6 +217,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-85 |i| |gi| |gg|
|
||||
@Test
|
||||
fun testInsertAtPreviousAction() {
|
||||
doTest(
|
||||
listOf("i", "hello", "<Esc>", "gg", "gi", " world! "),
|
||||
@ -218,6 +239,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-312 |d| |w|
|
||||
@Test
|
||||
fun testDeleteLastWordInFile() {
|
||||
doTest(
|
||||
"dw",
|
||||
@ -238,6 +260,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |w|
|
||||
@Test
|
||||
fun testDeleteLastWordBeforeEOL() {
|
||||
doTest(
|
||||
"dw",
|
||||
@ -257,6 +280,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-105 |d| |w|
|
||||
@Test
|
||||
fun testDeleteLastWordBeforeEOLs() {
|
||||
doTest(
|
||||
"dw",
|
||||
@ -278,6 +302,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-105 |d| |w|
|
||||
@Test
|
||||
fun testDeleteLastWordBeforeEOLAndWhitespace() {
|
||||
doTest(
|
||||
"dw",
|
||||
@ -294,6 +319,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-105 |d| |w| |count|
|
||||
@Test
|
||||
fun testDeleteTwoWordsOnTwoLines() {
|
||||
doTest(
|
||||
"d2w",
|
||||
@ -309,6 +335,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1380 |d| |w| |count|
|
||||
@Test
|
||||
fun testDeleteTwoWordsAtLastChar() {
|
||||
doTest(
|
||||
"d2w",
|
||||
@ -320,6 +347,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-394 |d| |v_aw|
|
||||
@Test
|
||||
fun testDeleteIndentedWordBeforePunctuation() {
|
||||
doTest(
|
||||
"daw",
|
||||
@ -335,6 +363,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_aw|
|
||||
@Test
|
||||
fun testDeleteLastWordAfterPunctuation() {
|
||||
doTest(
|
||||
"daw",
|
||||
@ -354,6 +383,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-244 |d| |l|
|
||||
@Test
|
||||
fun testDeleteLastCharInLine() {
|
||||
doTest(
|
||||
"dl",
|
||||
@ -374,6 +404,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-393 |d|
|
||||
@Test
|
||||
fun testDeleteBadArgument() {
|
||||
doTest(
|
||||
listOf("dD", "dd"),
|
||||
@ -389,6 +420,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-262 |i_CTRL-R|
|
||||
@Test
|
||||
fun testInsertFromRegister() {
|
||||
setRegister('a', "World")
|
||||
doTest(
|
||||
@ -401,6 +433,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-404 |O|
|
||||
@Test
|
||||
fun testInsertNewLineAboveFirstLine() {
|
||||
doTest(
|
||||
listOf("O", "bar"),
|
||||
@ -412,6 +445,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-472 |v|
|
||||
@Test
|
||||
fun testVisualSelectionRightMargin() {
|
||||
doTest(
|
||||
listOf("v", "k\$d"),
|
||||
@ -423,6 +457,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-632 |CTRL-V| |v_d|
|
||||
@Test
|
||||
fun testDeleteVisualBlock() {
|
||||
doTest(
|
||||
listOf("<C-V>", "jjl", "d"),
|
||||
@ -445,6 +480,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteCharVisualBlock() {
|
||||
doTest(
|
||||
listOf("<C-V>", "jjl", "x"),
|
||||
@ -467,6 +503,7 @@ class ChangeActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteJoinLinesSpaces() {
|
||||
doTest(
|
||||
"3J",
|
||||
@ -483,6 +520,7 @@ quux
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteJoinLines() {
|
||||
doTest(
|
||||
"3gJ",
|
||||
@ -500,6 +538,7 @@ quux
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(originalVimAfter = "foo bar")
|
||||
@Test
|
||||
fun testDeleteJoinLinesWithTrailingSpaceThenEmptyLine() {
|
||||
doTest(
|
||||
"3J",
|
||||
@ -514,6 +553,7 @@ quux
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteJoinLinesWithTwoTrailingSpaces() {
|
||||
doTest(
|
||||
"J",
|
||||
@ -527,6 +567,7 @@ quux
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteJoinVisualLinesSpaces() {
|
||||
doTest(
|
||||
"v2jJ",
|
||||
@ -543,6 +584,7 @@ quux
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteJoinVisualLines() {
|
||||
doTest(
|
||||
"v2jgJ",
|
||||
@ -559,6 +601,7 @@ quux
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteCharVisualBlockOnLastCharOfLine() {
|
||||
doTest(
|
||||
listOf("<C-V>", "x"),
|
||||
@ -569,6 +612,7 @@ quux
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteCharVisualBlockOnEmptyLinesDoesntDeleteAnything() {
|
||||
setupChecks {
|
||||
this.neoVim.ignoredRegisters = setOf('1', '"')
|
||||
@ -583,6 +627,7 @@ quux
|
||||
}
|
||||
|
||||
// VIM-781 |CTRL-V| |j|
|
||||
@Test
|
||||
fun testDeleteCharVisualBlockWithEmptyLineInTheMiddle() {
|
||||
doTest(
|
||||
listOf("l", "<C-V>", "jj", "x"),
|
||||
@ -605,6 +650,7 @@ quux
|
||||
|
||||
// VIM-781 |CTRL-V| |j|
|
||||
@VimBehaviorDiffers(description = "Different registers content")
|
||||
@Test
|
||||
fun testDeleteCharVisualBlockWithShorterLineInTheMiddle() {
|
||||
doTest(
|
||||
listOf("l", "<C-V>", "jj", "x"),
|
||||
@ -626,6 +672,7 @@ quux
|
||||
}
|
||||
|
||||
// VIM-845 |CTRL-V| |x|
|
||||
@Test
|
||||
fun testDeleteVisualBlockOneCharWide() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -645,23 +692,27 @@ quux
|
||||
}
|
||||
|
||||
// |r|
|
||||
@Test
|
||||
fun testReplaceOneChar() {
|
||||
doTest("rx", "b${c}ar\n", "b${c}xr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |r|
|
||||
@VimBehaviorDiffers(originalVimAfter = "foXX${c}Xr\n")
|
||||
@Test
|
||||
fun testReplaceMultipleCharsWithCount() {
|
||||
doTest("3rX", "fo${c}obar\n", "fo${c}XXXr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |r|
|
||||
@Test
|
||||
fun testReplaceMultipleCharsWithCountPastEndOfLine() {
|
||||
doTest("6rX", "fo${c}obar\n", "fo${c}obar\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |r|
|
||||
@VimBehaviorDiffers(description = "Different caret position")
|
||||
@Test
|
||||
fun testReplaceMultipleCharsWithVisual() {
|
||||
doTest(
|
||||
listOf("v", "ll", "j", "rZ"),
|
||||
@ -681,6 +732,7 @@ quux
|
||||
}
|
||||
|
||||
// |r|
|
||||
@Test
|
||||
fun testReplaceOneCharWithNewline() {
|
||||
doTest(
|
||||
"r<Enter>",
|
||||
@ -698,6 +750,7 @@ foobaz
|
||||
|
||||
// |r|
|
||||
@VimBehaviorDiffers(description = "Different caret position")
|
||||
@Test
|
||||
fun testReplaceCharWithNewlineAndCountAddsOnlySingleNewline() {
|
||||
doTest(
|
||||
"3r<Enter>",
|
||||
@ -714,11 +767,13 @@ foobaz
|
||||
}
|
||||
|
||||
// |s|
|
||||
@Test
|
||||
fun testReplaceOneCharWithText() {
|
||||
doTest("sxy<Esc>", "b${c}ar\n", "bx${c}yr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |s|
|
||||
@Test
|
||||
fun testReplaceMultipleCharsWithTextWithCount() {
|
||||
doTest(
|
||||
"3sxy<Esc>",
|
||||
@ -730,6 +785,7 @@ foobaz
|
||||
}
|
||||
|
||||
// |s|
|
||||
@Test
|
||||
fun testReplaceMultipleCharsWithTextWithCountPastEndOfLine() {
|
||||
doTest(
|
||||
"99sxyz<Esc>",
|
||||
@ -749,12 +805,14 @@ foobaz
|
||||
}
|
||||
|
||||
// |R|
|
||||
@Test
|
||||
fun testReplaceMode() {
|
||||
doTest("Rbaz<Esc>", "foo${c}bar\n", "fooba${c}z\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// |R| |i_<Insert>|
|
||||
@VimBehaviorDiffers(description = "Different caret position")
|
||||
@Test
|
||||
fun testReplaceModeSwitchToInsertModeAndBack() {
|
||||
doTest(
|
||||
"RXXX<Ins>YYY<Ins>ZZZ<Esc>",
|
||||
@ -767,6 +825,7 @@ foobaz
|
||||
|
||||
// |i| |i_<Insert>|
|
||||
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR, "<INS> works strange")
|
||||
@Test
|
||||
fun testInsertModeSwitchToReplaceModeAndBack() {
|
||||
doTest(
|
||||
"iXXX<Ins>YYY<Ins>ZZZ<Esc>",
|
||||
@ -779,6 +838,7 @@ foobaz
|
||||
|
||||
// VIM-511 |.|
|
||||
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR, "Backspace workspace strange")
|
||||
@Test
|
||||
fun testRepeatWithBackspaces() {
|
||||
doTest(
|
||||
listOf("ce", "foo", "<BS><BS><BS>", "foo", "<Esc>", "j0", "."),
|
||||
@ -799,6 +859,7 @@ foobaz
|
||||
|
||||
// VIM-511 |.|
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testRepeatWithParensAndQuotesAutoInsertion() {
|
||||
configureByJavaText(
|
||||
"""
|
||||
@ -819,6 +880,7 @@ foobaz
|
||||
|
||||
// VIM-511 |.|
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testDeleteBothParensAndStartAgain() {
|
||||
configureByJavaText(
|
||||
"""
|
||||
@ -838,6 +900,7 @@ foobaz
|
||||
}
|
||||
|
||||
// VIM-613 |.|
|
||||
@Test
|
||||
fun testDeleteEndOfLineAndAgain() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -860,6 +923,7 @@ foobaz
|
||||
|
||||
// VIM-511 |.|
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testAutoCompleteCurlyBraceWithEnterWithinFunctionBody() {
|
||||
configureByJavaText(
|
||||
"""
|
||||
@ -884,6 +948,7 @@ foobaz
|
||||
|
||||
// VIM-1067 |.|
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testRepeatWithInsertAfterLineEnd() {
|
||||
// Case 1
|
||||
configureByText(
|
||||
@ -944,6 +1009,7 @@ foobaz
|
||||
}
|
||||
|
||||
// VIM-287 |zc| |O|
|
||||
@Test
|
||||
fun testInsertAfterFold() {
|
||||
configureByJavaText(
|
||||
"""$c/**
|
||||
@ -967,6 +1033,7 @@ and some text after""",
|
||||
|
||||
// VIM-287 |zc| |o|
|
||||
@TestWithoutNeovim(SkipNeovimReason.FOLDING)
|
||||
@Test
|
||||
fun testInsertBeforeFold() {
|
||||
configureByJavaText(
|
||||
"""
|
||||
@ -979,9 +1046,9 @@ and some text after""",
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
myFixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
CodeFoldingManager.getInstance(myFixture.project).updateFoldRegions(myFixture.editor)
|
||||
FoldingUtil.findFoldRegionStartingAtLine(myFixture.editor, 0)!!.isExpanded = false
|
||||
fixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
CodeFoldingManager.getInstance(fixture.project).updateFoldRegions(fixture.editor)
|
||||
FoldingUtil.findFoldRegionStartingAtLine(fixture.editor, 0)!!.isExpanded = false
|
||||
}
|
||||
|
||||
typeText(injector.parser.parseKeys("o"))
|
||||
@ -998,6 +1065,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRepeatChangeWordDoesNotBreakNextRepeatFind() {
|
||||
doTest(
|
||||
"fXcfYPATATA<Esc>fX.;.",
|
||||
@ -1008,6 +1076,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRepeatReplace() {
|
||||
configureByText("${c}foobarbaz spam\n")
|
||||
typeText(injector.parser.parseKeys("R"))
|
||||
@ -1017,6 +1086,7 @@ and some text after""",
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDownMovementAfterDeletionToStart() {
|
||||
doTest(
|
||||
"ld^j",
|
||||
@ -1033,6 +1103,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDownMovementAfterDeletionToPrevWord() {
|
||||
doTest(
|
||||
"ldbj",
|
||||
@ -1049,6 +1120,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDownMovementAfterChangeToPrevWord() {
|
||||
doTest(
|
||||
"lcb<Esc>j",
|
||||
@ -1065,6 +1137,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDownMovementAfterChangeToLineStart() {
|
||||
doTest(
|
||||
"lc^<Esc>j",
|
||||
@ -1081,6 +1154,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUpMovementAfterDeletionToStart() {
|
||||
doTest(
|
||||
"ld^k",
|
||||
@ -1097,6 +1171,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUpMovementAfterChangeToPrevWord() {
|
||||
doTest(
|
||||
"lcb<Esc>k",
|
||||
@ -1114,6 +1189,7 @@ and some text after""",
|
||||
}
|
||||
|
||||
// VIM-714 |v|
|
||||
@Test
|
||||
fun testDeleteVisualColumnPositionOneLine() {
|
||||
doTest(
|
||||
"vwxj",
|
||||
@ -1133,6 +1209,7 @@ and some text after""",
|
||||
}
|
||||
|
||||
// VIM-714 |v|
|
||||
@Test
|
||||
fun testDeleteVisualColumnPositionMultiLine() {
|
||||
doTest(
|
||||
"v3wfixj",
|
||||
@ -1152,6 +1229,7 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeSameLine() {
|
||||
doTest(
|
||||
"d_",
|
||||
|
@ -10,28 +10,35 @@ package org.jetbrains.plugins.ideavim.action
|
||||
import com.google.common.collect.Lists
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeNumberActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun testIncrementDecimalZero() {
|
||||
doTest("<C-A>", "0", "1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementHexZero() {
|
||||
doTest("<C-A>", "0x0", "0x1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementZero() {
|
||||
doTest("<C-X>", "0", "-1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementDecimal() {
|
||||
doTest("<C-A>", "199", "200", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementDecimal() {
|
||||
doTest("<C-X>", "1000", "999", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementOctal() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
|
||||
@ -42,6 +49,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementOctal() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"),
|
||||
@ -52,22 +60,27 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementHex() {
|
||||
doTest("<C-A>", "0xff", "0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementHex() {
|
||||
doTest("<C-X>", "0xa100", "0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementNegativeDecimal() {
|
||||
doTest("<C-A>", "-199", "-198", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementNegativeDecimal() {
|
||||
doTest("<C-X>", "-1000", "-1001", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementNegativeOctal() {
|
||||
// Minus isn't processed
|
||||
doTest(
|
||||
@ -79,6 +92,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementNegativeOctal() {
|
||||
// Minus isn't processed
|
||||
doTest(
|
||||
@ -90,26 +104,32 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementNegativeHex() {
|
||||
doTest("<C-A>", "-0xff", "-0x100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementNegativeHex() {
|
||||
doTest("<C-X>", "-0xa100", "-0xa0ff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementWithCount() {
|
||||
doTest("123<C-A>", "456", "579", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecrementWithCount() {
|
||||
doTest("200<C-X>", "100", "-100", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementAlphaWithoutNumberFormatAlpha() {
|
||||
doTest("<C-A>", "foo", "foo", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementAlphaWithNumberFormatAlpha() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
|
||||
@ -120,6 +140,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementZWithNumberFormatAlpha() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
|
||||
@ -130,6 +151,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementXInHexNumberWithNumberFormatAlphaButNotHex() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
|
||||
@ -140,6 +162,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementXInHexNumberWithNumberFormatHexAlpha() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"),
|
||||
@ -150,6 +173,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementHexNumberWithoutNumberFormatHex() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
|
||||
@ -160,6 +184,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementOctalNumberWithoutNumberFormatOctal() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"),
|
||||
@ -170,6 +195,7 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementNegativeOctalNumberWithoutNumberFormatOctal() {
|
||||
doTest(
|
||||
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"),
|
||||
@ -180,14 +206,17 @@ class ChangeNumberActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementHexPreservesCaseOfX() {
|
||||
doTest("<C-A>", "0X88", "0X89", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementHexTakesCaseFromLastLetter() {
|
||||
doTest("<C-A>", "0xaB0", "0xAB1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementLocatesNumberOnTheSameLine() {
|
||||
doTest(
|
||||
"<C-A>",
|
||||
|
@ -12,20 +12,24 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class CommandCountTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test count operator motion`() {
|
||||
configureByText("${c}1234567890")
|
||||
typeText(injector.parser.parseKeys("3dl"))
|
||||
assertState("4567890")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test operator count motion`() {
|
||||
configureByText("${c}1234567890")
|
||||
typeText(injector.parser.parseKeys("d3l"))
|
||||
assertState("4567890")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test count operator count motion`() {
|
||||
configureByText("${c}1234567890")
|
||||
typeText(injector.parser.parseKeys("2d3l"))
|
||||
@ -33,12 +37,14 @@ class CommandCountTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// See https://github.com/vim/vim/blob/b376ace1aeaa7614debc725487d75c8f756dd773/src/normal.c#L631
|
||||
@Test
|
||||
fun `test count resets to 999999999L if gets too large`() {
|
||||
configureByText("1")
|
||||
typeText(injector.parser.parseKeys("12345678901234567890<C-A>"))
|
||||
assertState("1000000000")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test count select register count operator count motion`() {
|
||||
configureByText("${c}123456789012345678901234567890")
|
||||
typeText(injector.parser.parseKeys("2\"a3d4l")) // Delete 24 characters
|
||||
@ -46,6 +52,7 @@ class CommandCountTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun `test multiple select register counts`() {
|
||||
configureByText("${c}12345678901234567890123456789012345678901234567890")
|
||||
typeText(injector.parser.parseKeys("2\"a2\"b2\"b2d2l")) // Delete 32 characters
|
||||
|
@ -13,6 +13,8 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
@ -20,12 +22,14 @@ import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
@Suppress("SpellCheckingInspection")
|
||||
class CopyActionTest : VimTestCase() {
|
||||
// |y| |p| |count|
|
||||
@Test
|
||||
fun testYankPutCharacters() {
|
||||
typeTextInFile("y2h" + "p", "one two<caret> three\n")
|
||||
assertState("one twwoo three\n")
|
||||
}
|
||||
|
||||
// |yy|
|
||||
@Test
|
||||
fun testYankLine() {
|
||||
typeTextInFile(
|
||||
"yy" + "p",
|
||||
@ -48,6 +52,7 @@ class CopyActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-723 |p|
|
||||
@Test
|
||||
fun testYankPasteToEmptyLine() {
|
||||
typeTextInFile(
|
||||
"yiw" + "j" + "p",
|
||||
@ -69,6 +74,7 @@ class CopyActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-390 |yy| |p|
|
||||
@Test
|
||||
fun testYankLinePasteAtLastLine() {
|
||||
typeTextInFile(
|
||||
"yy" + "p",
|
||||
@ -89,6 +95,7 @@ class CopyActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |register| |y|
|
||||
@Test
|
||||
fun testYankRegister() {
|
||||
typeTextInFile("\"ayl" + "l" + "\"byl" + "\"ap" + "\"bp", "hel<caret>lo world\n")
|
||||
assertState("hellolo world\n")
|
||||
@ -96,29 +103,34 @@ class CopyActionTest : VimTestCase() {
|
||||
|
||||
// |register| |y| |quote|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testYankRegisterUsesLastEnteredRegister() {
|
||||
typeTextInFile("\"a\"byl" + "\"ap", "hel<caret>lo world\n")
|
||||
assertState("helllo world\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testYankAppendRegister() {
|
||||
typeTextInFile("\"Ayl" + "l" + "\"Ayl" + "\"Ap", "hel<caret>lo world\n")
|
||||
assertState("hellolo world\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testYankWithInvalidRegister() {
|
||||
typeTextInFile("\"&", "hel<caret>lo world\n")
|
||||
assertPluginError(true)
|
||||
}
|
||||
|
||||
// |P|
|
||||
@Test
|
||||
fun testYankPutBefore() {
|
||||
typeTextInFile("y2l" + "P", "<caret>two\n")
|
||||
assertState("twtwo\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.PLUGIN_ERROR)
|
||||
@Test
|
||||
fun testWrongYankQuoteMotion() {
|
||||
assertPluginError(false)
|
||||
typeTextInFile(
|
||||
@ -133,6 +145,7 @@ class CopyActionTest : VimTestCase() {
|
||||
assertPluginError(true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWrongYankQuoteYankLine() {
|
||||
assertPluginError(false)
|
||||
typeTextInFile(
|
||||
@ -156,6 +169,7 @@ class CopyActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWrongYankRegisterMotion() {
|
||||
val editor = typeTextInFile(
|
||||
"y\"" + "0",
|
||||
@ -166,10 +180,11 @@ class CopyActionTest : VimTestCase() {
|
||||
|
||||
""".trimIndent(),
|
||||
)
|
||||
assertEquals(0, editor.caretModel.offset)
|
||||
kotlin.test.assertEquals(0, editor.caretModel.offset)
|
||||
}
|
||||
|
||||
// VIM-632 |CTRL-V| |v_y| |p|
|
||||
@Test
|
||||
fun testYankVisualBlock() {
|
||||
typeTextInFile(
|
||||
"<C-V>" + "jl" + "yl" + "p",
|
||||
@ -199,6 +214,7 @@ class CopyActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-632 |CTRL-V| |v_y|
|
||||
@Test
|
||||
fun testStateAfterYankVisualBlock() {
|
||||
typeTextInFile(
|
||||
"<C-V>" + "jl" + "y",
|
||||
@ -216,6 +232,7 @@ class CopyActionTest : VimTestCase() {
|
||||
// VIM-476 |yy| |'clipboard'|
|
||||
// TODO: Review this test
|
||||
// This doesn't use the system clipboard, but the TestClipboardModel
|
||||
@Test
|
||||
fun testClipboardUnnamed() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -225,24 +242,25 @@ class CopyActionTest : VimTestCase() {
|
||||
|
||||
""".trimIndent(),
|
||||
)
|
||||
assertEquals('\"', VimPlugin.getRegister().defaultRegister)
|
||||
kotlin.test.assertEquals('\"', VimPlugin.getRegister().defaultRegister)
|
||||
enterCommand("set clipboard=unnamed")
|
||||
assertEquals('*', VimPlugin.getRegister().defaultRegister)
|
||||
kotlin.test.assertEquals('*', VimPlugin.getRegister().defaultRegister)
|
||||
typeText("yy")
|
||||
val starRegister = VimPlugin.getRegister().getRegister('*')
|
||||
assertNotNull(starRegister)
|
||||
assertEquals("bar\n", starRegister!!.text)
|
||||
assertNotNull<Any>(starRegister)
|
||||
kotlin.test.assertEquals("bar\n", starRegister.text)
|
||||
}
|
||||
|
||||
// VIM-792 |"*| |yy| |p|
|
||||
// TODO: Review this test
|
||||
// This doesn't use the system clipboard, but the TestClipboardModel
|
||||
@Test
|
||||
fun testLineWiseClipboardYankPaste() {
|
||||
configureByText("<caret>foo\n")
|
||||
typeText("\"*yy" + "\"*p")
|
||||
val register = VimPlugin.getRegister().getRegister('*')
|
||||
assertNotNull(register)
|
||||
assertEquals("foo\n", register!!.text)
|
||||
assertNotNull<Any>(register)
|
||||
kotlin.test.assertEquals("foo\n", register.text)
|
||||
assertState(
|
||||
"""
|
||||
foo
|
||||
@ -256,6 +274,7 @@ class CopyActionTest : VimTestCase() {
|
||||
// TODO: Review this test
|
||||
// This doesn't use the system clipboard, but the TestClipboardModel
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testBlockWiseClipboardYankPaste() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -267,13 +286,13 @@ class CopyActionTest : VimTestCase() {
|
||||
)
|
||||
typeText("<C-V>j" + "\"*y" + "\"*p")
|
||||
val register = VimPlugin.getRegister().getRegister('*')
|
||||
assertNotNull(register)
|
||||
assertEquals(
|
||||
assertNotNull<Any>(register)
|
||||
kotlin.test.assertEquals(
|
||||
"""
|
||||
f
|
||||
b
|
||||
""".trimIndent(),
|
||||
register!!.text,
|
||||
register.text
|
||||
)
|
||||
assertState(
|
||||
"""
|
||||
@ -287,12 +306,14 @@ class CopyActionTest : VimTestCase() {
|
||||
|
||||
// VIM-1431
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testPutInEmptyFile() {
|
||||
VimPlugin.getRegister().setKeys('a', injector.parser.parseKeys("test"))
|
||||
typeTextInFile("\"ap", "")
|
||||
assertState("test")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOverridingRegisterWithEmptyTag() {
|
||||
configureByText(
|
||||
"""
|
||||
|
@ -12,9 +12,11 @@ import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class FileGetLocationInfoActionTest : VimTestCase() {
|
||||
@VimBehaviorDiffers(originalVimAfter = "Col 1 of 11; Line 1 of 6; Word 1 of 32; Byte 1 of 166")
|
||||
@Test
|
||||
fun `test get file info`() {
|
||||
val keys = injector.parser.parseKeys("g<C-G>")
|
||||
val before = """
|
||||
@ -27,10 +29,11 @@ class FileGetLocationInfoActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
typeText(keys)
|
||||
assertEquals("Col 1 of 11; Line 1 of 6; Word 1 of 34; Character 1 of 165", VimPlugin.getMessage())
|
||||
kotlin.test.assertEquals("Col 1 of 11; Line 1 of 6; Word 1 of 34; Character 1 of 165", VimPlugin.getMessage())
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(originalVimAfter = "Col 1 of 11; Line 1 of 7; Word 1 of 32; Byte 1 of 167")
|
||||
@Test
|
||||
fun `test get file info with empty line`() {
|
||||
val keys = injector.parser.parseKeys("g<C-G>")
|
||||
val before = """
|
||||
@ -44,10 +47,11 @@ class FileGetLocationInfoActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
typeText(keys)
|
||||
assertEquals("Col 1 of 11; Line 1 of 7; Word 1 of 35; Character 1 of 166", VimPlugin.getMessage())
|
||||
kotlin.test.assertEquals("Col 1 of 11; Line 1 of 7; Word 1 of 35; Character 1 of 166", VimPlugin.getMessage())
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(originalVimAfter = "Col 1 of 40; Line 4 of 7; Word 12 of 32; Byte 55 of 167")
|
||||
@Test
|
||||
fun `test get file info in the middle`() {
|
||||
val keys = injector.parser.parseKeys("g<C-G>")
|
||||
val before = """
|
||||
@ -61,10 +65,11 @@ class FileGetLocationInfoActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
typeText(keys)
|
||||
assertEquals("Col 11 of 40; Line 4 of 7; Word 13 of 35; Character 55 of 166", VimPlugin.getMessage())
|
||||
kotlin.test.assertEquals("Col 11 of 40; Line 4 of 7; Word 13 of 35; Character 55 of 166", VimPlugin.getMessage())
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(originalVimAfter = "Col 1 of 0; Line 7 of 7; Word 32 of 32; Byte 167 of 167")
|
||||
@Test
|
||||
fun `test get file info on the last line`() {
|
||||
val keys = injector.parser.parseKeys("g<C-G>")
|
||||
val before = """
|
||||
@ -78,6 +83,6 @@ class FileGetLocationInfoActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
typeText(keys)
|
||||
assertEquals("Col 1 of 1; Line 7 of 7; Word 35 of 35; Character 167 of 166", VimPlugin.getMessage())
|
||||
kotlin.test.assertEquals("Col 1 of 1; Line 7 of 7; Word 35 of 35; Character 167 of 166", VimPlugin.getMessage())
|
||||
}
|
||||
}
|
||||
|
@ -13,21 +13,22 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertDoesNotThrow
|
||||
|
||||
class GuardedBlocksTest : VimTestCase() {
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
fun `ignoretest delete char with block`() {
|
||||
@Test
|
||||
fun `test delete char with block`() {
|
||||
configureAndGuard("[123${c}4567890]")
|
||||
try {
|
||||
assertDoesNotThrow {
|
||||
typeText(injector.parser.parseKeys("x"))
|
||||
} catch (e: Throwable) {
|
||||
// Catch exception
|
||||
return
|
||||
}
|
||||
fail()
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
fun `test delete line with block`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
@ -46,9 +47,10 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
// Probably it's better to put the caret after 1
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test delete line with block and longer start`() {
|
||||
configureAndGuard("""
|
||||
[1234567890
|
||||
@ -62,10 +64,10 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent())
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test delete line with block and shorter end`() {
|
||||
configureAndGuard("""
|
||||
[1234567890
|
||||
@ -79,10 +81,11 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1234567890
|
||||
""".trimIndent())
|
||||
}
|
||||
*/
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
fun `ignoretest delete line fully unmodifiable`() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test delete line fully unmodifiable`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
[123${c}4567890
|
||||
@ -101,7 +104,9 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
fun `ignoretest delete line fully unmodifiable end`() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test delete line fully unmodifiable end`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
[1234567890
|
||||
@ -120,7 +125,9 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
fun `ignoretest change line with block`() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test change line with block`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
[1234567890
|
||||
@ -140,6 +147,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
fun `test change line with block1`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
@ -161,6 +169,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
fun `test change line with block2`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
@ -181,8 +190,9 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
assertMode(VimStateMachine.Mode.INSERT)
|
||||
}
|
||||
|
||||
/*
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test change line with block with longer start`() {
|
||||
configureAndGuard("""
|
||||
[1234567890
|
||||
@ -195,12 +205,12 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
1${c}
|
||||
1234567890
|
||||
""".trimIndent())
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
assertMode(VimStateMachine.Mode.INSERT)
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test change line with block with shorter end`() {
|
||||
configureAndGuard("""
|
||||
[1234567890
|
||||
@ -213,12 +223,13 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
${c}0
|
||||
1234567890
|
||||
""".trimIndent())
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
assertMode(VimStateMachine.Mode.INSERT)
|
||||
}
|
||||
*/
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
fun `ignoretest change line with block at the end`() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test change line with block at the end`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
[1234567890
|
||||
@ -236,6 +247,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
fun `test delete line near the guard`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
@ -254,7 +266,9 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
fun `ignoretest delete line near the guard with line above`() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test delete line near the guard with line above`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
1234567890
|
||||
@ -273,6 +287,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
fun `test change line near the guard with line above`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
@ -293,6 +308,7 @@ class GuardedBlocksTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.GUARDED_BLOCKS)
|
||||
@Test
|
||||
fun `test delete line near the guard with line above on empty line`() {
|
||||
configureAndGuard(
|
||||
"""
|
||||
|
@ -11,44 +11,49 @@ 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.newapi.vim
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.jetbrains.plugins.ideavim.rangeOf
|
||||
import org.jetbrains.plugins.ideavim.waitAndAssert
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
class MacroActionTest : VimTestCase() {
|
||||
// |q|
|
||||
@Test
|
||||
fun testRecordMacro() {
|
||||
val editor = typeTextInFile(injector.parser.parseKeys("qa" + "3l" + "q"), "on<caret>e two three\n")
|
||||
val commandState = editor.vim.vimStateMachine
|
||||
assertFalse(commandState.isRecording)
|
||||
kotlin.test.assertFalse(commandState.isRecording)
|
||||
val registerGroup = VimPlugin.getRegister()
|
||||
val register = registerGroup.getRegister('a')
|
||||
assertNotNull(register)
|
||||
assertEquals("3l", register!!.text)
|
||||
assertNotNull<Any>(register)
|
||||
kotlin.test.assertEquals("3l", register.text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRecordMacroDoesNotExpandMap() {
|
||||
configureByText("")
|
||||
enterCommand("imap pp hello")
|
||||
typeText(injector.parser.parseKeys("qa" + "i" + "pp<Esc>" + "q"))
|
||||
val register = VimPlugin.getRegister().getRegister('a')
|
||||
assertNotNull(register)
|
||||
assertEquals("ipp<Esc>", injector.parser.toKeyNotation(register!!.keys))
|
||||
assertNotNull<Any>(register)
|
||||
kotlin.test.assertEquals("ipp<Esc>", injector.parser.toKeyNotation(register.keys))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRecordMacroWithDigraph() {
|
||||
typeTextInFile(injector.parser.parseKeys("qa" + "i" + "<C-K>OK<Esc>" + "q"), "")
|
||||
val register = VimPlugin.getRegister().getRegister('a')
|
||||
assertNotNull(register)
|
||||
assertEquals("i<C-K>OK<Esc>", injector.parser.toKeyNotation(register!!.keys))
|
||||
assertNotNull<Any>(register)
|
||||
kotlin.test.assertEquals("i<C-K>OK<Esc>", injector.parser.toKeyNotation(register.keys))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test macro with search`() {
|
||||
val content = """
|
||||
A Discovery
|
||||
@ -64,10 +69,11 @@ class MacroActionTest : VimTestCase() {
|
||||
val startOffset = content.rangeOf("rocks").startOffset
|
||||
|
||||
waitAndAssert {
|
||||
startOffset == myFixture.editor.caretModel.offset
|
||||
startOffset == fixture.editor.caretModel.offset
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test macro with command`() {
|
||||
val content = """
|
||||
A Discovery
|
||||
@ -82,9 +88,10 @@ class MacroActionTest : VimTestCase() {
|
||||
|
||||
val register = VimPlugin.getRegister().getRegister('a')
|
||||
val registerSize = register!!.keys.size
|
||||
TestCase.assertEquals(9, registerSize)
|
||||
kotlin.test.assertEquals(9, registerSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test last command`() {
|
||||
val content = "${c}0\n1\n2\n3\n"
|
||||
configureByText(content)
|
||||
@ -92,6 +99,7 @@ class MacroActionTest : VimTestCase() {
|
||||
assertState("2\n3\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test last command with count`() {
|
||||
val content = "${c}0\n1\n2\n3\n4\n5\n"
|
||||
configureByText(content)
|
||||
@ -99,6 +107,7 @@ class MacroActionTest : VimTestCase() {
|
||||
assertState("5\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test last command as last macro with count`() {
|
||||
val content = "${c}0\n1\n2\n3\n4\n5\n"
|
||||
configureByText(content)
|
||||
@ -106,6 +115,7 @@ class MacroActionTest : VimTestCase() {
|
||||
assertState("5\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test last command as last macro multiple times`() {
|
||||
val content = "${c}0\n1\n2\n3\n4\n5\n"
|
||||
configureByText(content)
|
||||
@ -129,13 +139,14 @@ class MacroActionTest : VimTestCase() {
|
||||
val startOffset = content.rangeOf("rocks").startOffset
|
||||
|
||||
waitAndAssert {
|
||||
println(myFixture.editor.caretModel.offset)
|
||||
println(fixture.editor.caretModel.offset)
|
||||
println(startOffset)
|
||||
println()
|
||||
startOffset == myFixture.editor.caretModel.offset
|
||||
startOffset == fixture.editor.caretModel.offset
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test macro with count`() {
|
||||
configureByText("${c}0\n1\n2\n3\n4\n5\n")
|
||||
typeText(injector.parser.parseKeys("qajq" + "4@a"))
|
||||
@ -143,6 +154,7 @@ class MacroActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT, "Reports differences in 'a register")
|
||||
@Test
|
||||
fun `test stop on error`() {
|
||||
val content = """
|
||||
A Discovery
|
||||
|
@ -14,9 +14,11 @@ import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.jetbrains.plugins.ideavim.waitAndAssert
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MacroWithEditingTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test print macro`() {
|
||||
typeTextInFile(injector.parser.parseKeys("qa" + "iHello<Esc>" + "q"), "")
|
||||
setText("")
|
||||
@ -24,23 +26,25 @@ class MacroWithEditingTest : VimTestCase() {
|
||||
assertState("iHello" + 27.toChar())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test copy and perform macro`() {
|
||||
typeTextInFile(injector.parser.parseKeys("^v\$h\"wy"), "iHello<Esc>")
|
||||
assertEquals("iHello<Esc>", VimPlugin.getRegister().getRegister('w')?.rawText)
|
||||
kotlin.test.assertEquals("iHello<Esc>", VimPlugin.getRegister().getRegister('w')?.rawText)
|
||||
setText("")
|
||||
typeText(injector.parser.parseKeys("@w"))
|
||||
waitAndAssert {
|
||||
myFixture.editor.document.text == "Hello"
|
||||
fixture.editor.document.text == "Hello"
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test copy and perform macro ctrl_a`() {
|
||||
typeTextInFile(injector.parser.parseKeys("^v\$h\"wy"), "<C-A>")
|
||||
assertEquals("<C-A>", VimPlugin.getRegister().getRegister('w')?.rawText)
|
||||
kotlin.test.assertEquals("<C-A>", VimPlugin.getRegister().getRegister('w')?.rawText)
|
||||
setText("1")
|
||||
typeText(injector.parser.parseKeys("@w"))
|
||||
waitAndAssert {
|
||||
myFixture.editor.document.text == "2"
|
||||
fixture.editor.document.text == "2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,13 @@ import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
class MarkTest : VimTestCase() {
|
||||
// |m|
|
||||
@Test
|
||||
fun testLocalMark() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("ma"),
|
||||
@ -28,14 +31,15 @@ class MarkTest : VimTestCase() {
|
||||
baz
|
||||
""",
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'a')
|
||||
assertNotNull(mark)
|
||||
assertEquals(1, mark!!.line)
|
||||
assertEquals(6, mark.col)
|
||||
assertNotNull<Any>(mark)
|
||||
kotlin.test.assertEquals(1, mark.line)
|
||||
kotlin.test.assertEquals(6, mark.col)
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testGlobalMark() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mG"),
|
||||
@ -44,14 +48,15 @@ class MarkTest : VimTestCase() {
|
||||
baz
|
||||
""",
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'G')
|
||||
assertNotNull(mark)
|
||||
assertEquals(1, mark!!.line)
|
||||
assertEquals(6, mark.col)
|
||||
assertNotNull<Any>(mark)
|
||||
kotlin.test.assertEquals(1, mark.line)
|
||||
kotlin.test.assertEquals(6, mark.col)
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testMarkIsDeletedWhenLineIsDeleted() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mx" + "dd"),
|
||||
@ -60,12 +65,13 @@ class MarkTest : VimTestCase() {
|
||||
baz
|
||||
""",
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'x')
|
||||
assertNull(mark)
|
||||
kotlin.test.assertNull(mark)
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testMarkIsNotDeletedWhenLineIsOneCharAndReplaced() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("ma" + "r1"),
|
||||
@ -76,12 +82,13 @@ class MarkTest : VimTestCase() {
|
||||
|
||||
""".trimIndent(),
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'a')
|
||||
assertNotNull(mark)
|
||||
assertNotNull<Any>(mark)
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testMarkIsNotDeletedWhenLineIsChanged() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("ma" + "cc"),
|
||||
@ -90,12 +97,13 @@ class MarkTest : VimTestCase() {
|
||||
baz
|
||||
""",
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'a')
|
||||
assertNotNull(mark)
|
||||
assertNotNull<Any>(mark)
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testMarkIsMovedUpWhenLinesArePartiallyDeletedAbove() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mx" + "2k" + "dd" + "0dw"),
|
||||
@ -104,14 +112,15 @@ class MarkTest : VimTestCase() {
|
||||
ba<caret>z
|
||||
""",
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'x')
|
||||
assertNotNull(mark)
|
||||
assertEquals(1, mark!!.line)
|
||||
assertEquals(6, mark.col)
|
||||
assertNotNull<Any>(mark)
|
||||
kotlin.test.assertEquals(1, mark.line)
|
||||
kotlin.test.assertEquals(6, mark.col)
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testMarkIsMovedUpWhenLinesAreDeletedAbove() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mx" + "2k" + "2dd"),
|
||||
@ -120,14 +129,15 @@ class MarkTest : VimTestCase() {
|
||||
ba<caret>z
|
||||
""",
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'x')
|
||||
assertNotNull(mark)
|
||||
assertEquals(0, mark!!.line)
|
||||
assertEquals(6, mark.col)
|
||||
assertNotNull<Any>(mark)
|
||||
kotlin.test.assertEquals(0, mark.line)
|
||||
kotlin.test.assertEquals(6, mark.col)
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testMarkIsMovedDownWhenLinesAreInsertedAbove() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mY" + "Obiff"),
|
||||
@ -138,10 +148,10 @@ class MarkTest : VimTestCase() {
|
||||
|
||||
""".trimIndent(),
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'Y')
|
||||
assertNotNull(mark)
|
||||
assertEquals(2, mark!!.line)
|
||||
assertNotNull<Any>(mark)
|
||||
kotlin.test.assertEquals(2, mark.line)
|
||||
|
||||
// Currently broken, needs investigation
|
||||
// Because of some reason system mark is recreated. As we're on a different column at this moment, this breaks test
|
||||
@ -151,6 +161,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |m|
|
||||
@Test
|
||||
fun testMarkIsMovedDownWhenLinesAreInsertedAboveWithIndentation() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mY" + "Obiff"),
|
||||
@ -159,10 +170,10 @@ class MarkTest : VimTestCase() {
|
||||
baz
|
||||
""",
|
||||
)
|
||||
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
|
||||
val vimEditor: VimEditor = IjVimEditor(fixture.editor)
|
||||
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'Y')
|
||||
assertNotNull(mark)
|
||||
assertEquals(2, mark!!.line)
|
||||
assertNotNull<Any>(mark)
|
||||
kotlin.test.assertEquals(2, mark.line)
|
||||
|
||||
// Currently broken, needs investigation
|
||||
// Because of some reason system mark is recreated. As we're on a different column at this moment, this breaks test
|
||||
@ -172,6 +183,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |m| |`|
|
||||
@Test
|
||||
fun testMarkAndJumpToMark() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("6l" + "mZ" + "G$" + "`Z"),
|
||||
@ -184,6 +196,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |m| |'|
|
||||
@Test
|
||||
fun testMarkAndJumpToMarkLeadingSpace() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("6l" + "mb" + "G$" + "'b"),
|
||||
@ -196,6 +209,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |m| |`|
|
||||
@Test
|
||||
fun testDeleteBacktickMotionIsCharacterWise() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mk" + "kh" + "d`k"),
|
||||
@ -214,6 +228,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |m| |`|
|
||||
@Test
|
||||
fun testDeleteSingleQuoteMotionIsLineWise() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("mk" + "kh" + "d'k"),
|
||||
@ -232,6 +247,7 @@ class MarkTest : VimTestCase() {
|
||||
|
||||
// VIM-43 |i| |`.|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testGotoLastChangePosition() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("i" + "hello " + "<Esc>" + "gg" + "`."),
|
||||
@ -246,6 +262,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-43 |p| |`.|
|
||||
@Test
|
||||
fun testGotoLastPutPosition() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("yy" + "p" + "gg" + "`."),
|
||||
@ -260,6 +277,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |i| |`]|
|
||||
@Test
|
||||
fun testGotoLastChangePositionEnd() {
|
||||
doTest(
|
||||
Lists.newArrayList("yiw", "P", "gg", "`]"),
|
||||
@ -281,6 +299,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT, "This test freezes")
|
||||
@Test
|
||||
fun testVisualMarks() {
|
||||
configureByText("Oh, <caret>hi Mark")
|
||||
typeText(injector.parser.parseKeys("vw<Esc>"))
|
||||
@ -290,6 +309,7 @@ class MarkTest : VimTestCase() {
|
||||
assertOffset(7)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testVisualMarksForBackwardsSelection() {
|
||||
configureByText("Oh, hi <caret>Mark")
|
||||
typeText(injector.parser.parseKeys("vb<Esc>"))
|
||||
@ -301,6 +321,7 @@ class MarkTest : VimTestCase() {
|
||||
|
||||
// we change start mark, but actually the start and end has changed
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT, "This test freezes")
|
||||
@Test
|
||||
fun testChangeSelectionStartMarkToBelowPosition() {
|
||||
configureByText("lala\nl<caret>alala\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3l<Esc>"))
|
||||
@ -316,6 +337,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// we change end mark and only end changes
|
||||
@Test
|
||||
fun testChangeSelectionEndMarkToBelowPosition() {
|
||||
configureByText("lala\nl<caret>alala\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3l<Esc>"))
|
||||
@ -331,6 +353,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// we change start mark, but end changes
|
||||
@Test
|
||||
fun testChangeReversedSelectionStartMarkToBelowPosition() {
|
||||
configureByText("lala\nlala<caret>la\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3h<Esc>"))
|
||||
@ -346,6 +369,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// we change end mark, but start and end are changed
|
||||
@Test
|
||||
fun testChangeReversedSelectionEndMarkToBelowPosition() {
|
||||
configureByText("lala\nlala<caret>la\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3h<Esc>"))
|
||||
@ -361,6 +385,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// we change start mark and only it changes
|
||||
@Test
|
||||
fun testChangeSelectionStartMarkToUpperPosition() {
|
||||
configureByText("lala\nl<caret>alala\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3l<Esc>"))
|
||||
@ -376,6 +401,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// we change end mark, but both start and end marks are changed
|
||||
@Test
|
||||
fun testChangeSelectionEndMarkToUpperPosition() {
|
||||
configureByText("lala\nl<caret>alala\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3l<Esc>"))
|
||||
@ -391,6 +417,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// we change end mark, but both start and end marks are changed
|
||||
@Test
|
||||
fun testChangeReversedSelectionStartMarkToUpperPosition() {
|
||||
configureByText("lala\nlala<caret>la\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3h<Esc>"))
|
||||
@ -406,6 +433,7 @@ class MarkTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// we change end mark, but both start and end marks are changed
|
||||
@Test
|
||||
fun testChangeReversedSelectionEndMarkToUpperPosition() {
|
||||
configureByText("lala\nlala<caret>la\nlala\n")
|
||||
typeText(injector.parser.parseKeys("v3h<Esc>"))
|
||||
@ -420,6 +448,7 @@ class MarkTest : VimTestCase() {
|
||||
assertOffset(9)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testVisualLineSelectionMarks() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -437,6 +466,7 @@ class MarkTest : VimTestCase() {
|
||||
assertOffset(199)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReversedVisualLineSelectionMarks() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -454,6 +484,7 @@ class MarkTest : VimTestCase() {
|
||||
assertOffset(199)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMulticaretMark() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -486,6 +517,7 @@ class MarkTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMulticaretSelectionMarks() {
|
||||
configureByText(
|
||||
"""
|
||||
|
@ -15,17 +15,20 @@ import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
class MotionActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun testDoubleToggleVisual() {
|
||||
val contents = "one tw${c}o\n"
|
||||
doTest("vv", contents, contents, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-198 |v_iw|
|
||||
@Test
|
||||
fun testVisualMotionInnerWordNewLineAtEOF() {
|
||||
val fileContents = "one tw${c}o\n"
|
||||
doTest(
|
||||
@ -38,6 +41,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |v_iW|
|
||||
@Test
|
||||
fun testVisualMotionInnerBigWord() {
|
||||
val fileContents = "one tw${c}o.three four\n"
|
||||
val fileContentsAfter = "one ${s}two.thre${c}e$se four\n"
|
||||
@ -45,6 +49,7 @@ class MotionActionTest : VimTestCase() {
|
||||
assertSelection("two.three")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEscapeInCommand() {
|
||||
val content = """
|
||||
on${c}e two
|
||||
@ -56,6 +61,7 @@ class MotionActionTest : VimTestCase() {
|
||||
assertOffset(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEscapeInCommandAndNumber() {
|
||||
val content = """
|
||||
on${c}e two
|
||||
@ -64,12 +70,13 @@ class MotionActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
doTest(listOf("12", "<Esc>"), content, content, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
assertPluginError(false)
|
||||
val vimCommandState = myFixture.editor.vimStateMachine
|
||||
val vimCommandState = fixture.editor.vimStateMachine
|
||||
kotlin.test.assertNotNull(vimCommandState)
|
||||
assertEmpty(vimCommandState.commandBuilder.keys.toList())
|
||||
}
|
||||
|
||||
// |h| |l|
|
||||
@Test
|
||||
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"
|
||||
@ -77,6 +84,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |j| |k|
|
||||
@Test
|
||||
fun testUpDownMove() {
|
||||
val before = """
|
||||
one
|
||||
@ -96,12 +104,14 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testDeleteDigitsInCount() {
|
||||
typeTextInFile(injector.parser.parseKeys("42<Delete>l"), "on${c}e two three four five six seven\n")
|
||||
assertOffset(6)
|
||||
}
|
||||
|
||||
// |f|
|
||||
@Test
|
||||
fun testForwardToTab() {
|
||||
val before = "on${c}e two\tthree\nfour\n"
|
||||
val after = "one two${c}\tthree\nfour\n"
|
||||
@ -109,6 +119,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testIllegalCharArgument() {
|
||||
typeTextInFile(injector.parser.parseKeys("f<Insert>"), "on${c}e two three four five six seven\n")
|
||||
assertOffset(2)
|
||||
@ -116,6 +127,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |F| |i_CTRL-K|
|
||||
@Test
|
||||
fun testBackToDigraph() {
|
||||
val before = "Hallo, Öster${c}reich!\n"
|
||||
val after = "Hallo, ${c}Österreich!\n"
|
||||
@ -124,6 +136,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-771 |t| |;|
|
||||
@Test
|
||||
fun testTillCharRight() {
|
||||
val keys = listOf("t:;")
|
||||
val before = "$c 1:a 2:b 3:c \n"
|
||||
@ -132,6 +145,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-771 |t| |;|
|
||||
@Test
|
||||
fun testTillCharRightRepeated() {
|
||||
val keys = listOf("t:;")
|
||||
val before = "$c 1:a 2:b 3:c \n"
|
||||
@ -140,6 +154,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-771 |t| |;|
|
||||
@Test
|
||||
fun testTillCharRightRepeatedWithCount2() {
|
||||
val keys = listOf("t:2;")
|
||||
val before = "$c 1:a 2:b 3:c \n"
|
||||
@ -148,6 +163,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-771 |t| |;|
|
||||
@Test
|
||||
fun testTillCharRightRepeatedWithCountHigherThan2() {
|
||||
val keys = listOf("t:3;")
|
||||
val before = "$c 1:a 2:b 3:c \n"
|
||||
@ -156,6 +172,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-771 |t| |,|
|
||||
@Test
|
||||
fun testTillCharRightReverseRepeated() {
|
||||
val keys = listOf("t:,,")
|
||||
val before = " 1:a 2:b$c 3:c \n"
|
||||
@ -164,6 +181,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-771 |t| |,|
|
||||
@Test
|
||||
fun testTillCharRightReverseRepeatedWithCount2() {
|
||||
val keys = listOf("t:,2,")
|
||||
val before = " 1:a 2:b$c 3:c \n"
|
||||
@ -172,6 +190,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-771 |t| |,|
|
||||
@Test
|
||||
fun testTillCharRightReverseRepeatedWithCountHigherThan3() {
|
||||
val keys = listOf("t:,3,")
|
||||
val before = " 0:_ 1:a 2:b$c 3:c \n"
|
||||
@ -180,6 +199,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-314 |d| |v_iB|
|
||||
@Test
|
||||
fun testDeleteInnerCurlyBraceBlock() {
|
||||
val keys = listOf("di{")
|
||||
val before = "{foo, b${c}ar, baz}\n"
|
||||
@ -188,6 +208,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-314 |d| |v_iB|
|
||||
@Test
|
||||
fun testDeleteInnerCurlyBraceBlockCaretBeforeString() {
|
||||
val keys = listOf("di{")
|
||||
val before = "{foo, ${c}\"bar\", baz}\n"
|
||||
@ -196,6 +217,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_aB|
|
||||
@Test
|
||||
fun testDeleteOuterCurlyBraceBlock() {
|
||||
val keys = listOf("da{")
|
||||
val before = "x = {foo, b${c}ar, baz};\n"
|
||||
@ -205,6 +227,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-261 |c| |v_iB|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testChangeInnerCurlyBraceBlockMultiLine() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("ci{"),
|
||||
@ -225,6 +248,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_aw|
|
||||
@Test
|
||||
fun testDeleteOuterWord() {
|
||||
val keys = listOf("daw")
|
||||
val before = "one t${c}wo three\n"
|
||||
@ -233,6 +257,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_aW|
|
||||
@Test
|
||||
fun testDeleteOuterBigWord() {
|
||||
val keys = listOf("daW")
|
||||
val before = "one \"t${c}wo\" three\n"
|
||||
@ -241,6 +266,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_is|
|
||||
@Test
|
||||
fun testDeleteInnerSentence() {
|
||||
val keys = listOf("dis")
|
||||
val before = "Hello World! How a${c}re you? Bye.\n"
|
||||
@ -249,6 +275,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_as|
|
||||
@Test
|
||||
fun testDeleteOuterSentence() {
|
||||
val keys = listOf("das")
|
||||
val before = "Hello World! How a${c}re you? Bye.\n"
|
||||
@ -258,6 +285,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// |v_as|
|
||||
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testSentenceMotionPastStartOfFile() {
|
||||
val keys = listOf("8(")
|
||||
|
||||
@ -275,6 +303,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_ip|
|
||||
@Test
|
||||
fun testDeleteInnerParagraph() {
|
||||
val keys = listOf("dip")
|
||||
val before = """
|
||||
@ -297,6 +326,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_ap|
|
||||
@Test
|
||||
fun testDeleteOuterParagraph() {
|
||||
val keys = listOf("dap")
|
||||
val before = """
|
||||
@ -318,6 +348,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_a]|
|
||||
@Test
|
||||
fun testDeleteOuterBracketBlock() {
|
||||
val keys = listOf("da]")
|
||||
val before = """foo = [
|
||||
@ -331,6 +362,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_i]|
|
||||
@Test
|
||||
fun testDeleteInnerBracketBlock() {
|
||||
val keys = listOf("di]")
|
||||
val before = "foo = [one, t${c}wo];\n"
|
||||
@ -339,6 +371,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1287 |d| |v_i(|
|
||||
@Test
|
||||
fun testSelectInsideForStringLiteral() {
|
||||
val keys = listOf("di(")
|
||||
val before = "(text \"with quotes(and ${c}braces)\")"
|
||||
@ -347,6 +380,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1287 |d| |v_i{|
|
||||
@Test
|
||||
fun testBadlyNestedBlockInsideString() {
|
||||
val before = "{\"{foo, ${c}bar\", baz}}"
|
||||
val keys = listOf("di{")
|
||||
@ -355,6 +389,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1287 |d| |v_i{|
|
||||
@Test
|
||||
fun testDeleteInsideBadlyNestedBlock() {
|
||||
val before = "a{\"{foo}, ${c}bar\", baz}b}"
|
||||
val keys = listOf("di{")
|
||||
@ -363,6 +398,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1008 |c| |v_i{|
|
||||
@Test
|
||||
fun testDeleteInsideDoubleQuotesSurroundedBlockWithSingleQuote() {
|
||||
val before = "\"{do${c}esn't work}\""
|
||||
val keys = listOf("ci{")
|
||||
@ -371,6 +407,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1008 |c| |v_i{|
|
||||
@Test
|
||||
fun testDeleteInsideSingleQuotesSurroundedBlock() {
|
||||
val keys = listOf("ci{")
|
||||
val before = "'{does n${c}ot work}'"
|
||||
@ -379,6 +416,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1008 |c| |v_i{|
|
||||
@Test
|
||||
fun testDeleteInsideDoublySurroundedBlock() {
|
||||
val before = "<p class=\"{{ \$ctrl.so${c}meClassName }}\"></p>"
|
||||
val keys = listOf("ci{")
|
||||
@ -387,6 +425,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_i>|
|
||||
@Test
|
||||
fun testDeleteInnerAngleBracketBlock() {
|
||||
val keys = listOf("di>")
|
||||
val before = "Foo<Foo, B${c}ar> bar\n"
|
||||
@ -395,6 +434,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |v_a>|
|
||||
@Test
|
||||
fun testDeleteOuterAngleBracketBlock() {
|
||||
val keys = listOf("da>")
|
||||
val before = "Foo<Foo, B${c}ar> bar\n"
|
||||
@ -403,6 +443,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |d| |v_i"|
|
||||
@Test
|
||||
fun testDeleteInnerDoubleQuoteString() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "foo = \"bar b${c}az\";\n"
|
||||
@ -412,6 +453,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-132 |d| |v_a"|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testDeleteOuterDoubleQuoteString() {
|
||||
val keys = listOf("da\"")
|
||||
val before = "foo = \"bar b${c}az\";\n"
|
||||
@ -420,6 +462,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |d| |v_i"|
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringStart() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "foo = [\"one\", ${c}\"two\", \"three\"];\n"
|
||||
@ -428,6 +471,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |d| |v_i"|
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringEnd() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "foo = [\"one\", \"two${c}\", \"three\"];\n"
|
||||
@ -436,6 +480,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |d| |v_i"|
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringWithEscapes() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "foo = \"fo\\\"o b${c}ar\";\n"
|
||||
@ -444,6 +489,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |d| |v_i"|
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringBefore() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "f${c}oo = [\"one\", \"two\", \"three\"];\n"
|
||||
@ -451,6 +497,7 @@ class MotionActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringOddNumberOfQuotes() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "abc\"def${c}\"gh\"i"
|
||||
@ -458,6 +505,7 @@ class MotionActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringBetweenEvenNumberOfQuotes() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "abc\"def\"g${c}h\"ijk\"l"
|
||||
@ -465,6 +513,7 @@ class MotionActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringOddNumberOfQuotesOnLast() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "abcdef\"gh\"ij${c}\"kl"
|
||||
@ -472,6 +521,7 @@ class MotionActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteDoubleQuotedStringEvenNumberOfQuotesOnLast() {
|
||||
val keys = listOf("di\"")
|
||||
val before = "abc\"def\"gh\"ij${c}\"kl"
|
||||
@ -480,6 +530,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |v_i"|
|
||||
@Test
|
||||
fun testInnerDoubleQuotedStringSelection() {
|
||||
val keys = listOf("vi\"")
|
||||
val before = "foo = [\"o${c}ne\", \"two\"];\n"
|
||||
@ -488,6 +539,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |c| |v_i"|
|
||||
@Test
|
||||
fun testChangeEmptyQuotedString() {
|
||||
val keys = listOf("ci\"")
|
||||
val before = "foo = \"${c}\";\n"
|
||||
@ -496,6 +548,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |d| |v_i'|
|
||||
@Test
|
||||
fun testDeleteInnerSingleQuoteString() {
|
||||
val keys = listOf("di'")
|
||||
val before = "foo = 'bar b${c}az';\n"
|
||||
@ -504,6 +557,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-132 |d| |v_i`|
|
||||
@Test
|
||||
fun testDeleteInnerBackQuoteString() {
|
||||
val keys = listOf("di`")
|
||||
val before = "foo = `bar b${c}az`;\n"
|
||||
@ -513,6 +567,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-132 |d| |v_a'|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testDeleteOuterSingleQuoteString() {
|
||||
val keys = listOf("da'")
|
||||
val before = "foo = 'bar b${c}az';\n"
|
||||
@ -522,6 +577,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-132 |d| |v_a`|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testDeleteOuterBackQuoteString() {
|
||||
val keys = listOf("da`")
|
||||
val before = "foo = `bar b${c}az`;\n"
|
||||
@ -530,6 +586,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-2733
|
||||
@Test
|
||||
fun testDeleteOuterQuoteEmptyString() {
|
||||
val keys = listOf("da'")
|
||||
val before = """
|
||||
@ -546,6 +603,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-2733
|
||||
@Test
|
||||
fun testDeleteOuterQuoteEmptyString2() {
|
||||
val keys = listOf("da'")
|
||||
val before = """
|
||||
@ -562,6 +620,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-2733
|
||||
@Test
|
||||
fun testDeleteOuterDoubleQuoteEmptyString() {
|
||||
val keys = listOf("da\"")
|
||||
val before = """
|
||||
@ -578,6 +637,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-2733
|
||||
@Test
|
||||
fun testDeleteOuterDoubleQuoteEmptyString2() {
|
||||
val keys = listOf("da\"")
|
||||
val before = """
|
||||
@ -594,6 +654,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1427
|
||||
@Test
|
||||
fun testDeleteOuterTagWithCount() {
|
||||
val keys = listOf("d2at")
|
||||
val before = "<a><b><c>$c</c></b></a>"
|
||||
@ -602,6 +663,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-2113
|
||||
@Test
|
||||
fun testReplaceEmptyTagContent() {
|
||||
val keys = listOf("cit")
|
||||
val before = "<a><c>$c</c></a>"
|
||||
@ -609,6 +671,7 @@ class MotionActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteToDigraph() {
|
||||
val keys = listOf("d/<C-K>O:<CR>")
|
||||
val before = "ab${c}cdÖef"
|
||||
@ -617,6 +680,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |[(|
|
||||
@Test
|
||||
fun testUnmatchedOpenParenthesis() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("[("),
|
||||
@ -630,6 +694,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |[{|
|
||||
@Test
|
||||
fun testUnmatchedOpenBracketMultiLine() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("[{"),
|
||||
@ -642,6 +707,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |])|
|
||||
@Test
|
||||
fun testUnmatchedCloseParenthesisMultiLine() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("])"),
|
||||
@ -653,6 +719,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |]}|
|
||||
@Test
|
||||
fun testUnmatchedCloseBracket() {
|
||||
typeTextInFile(injector.parser.parseKeys("]}"), "{bar, ${c}baz}\n")
|
||||
assertOffset(9)
|
||||
@ -660,6 +727,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-965 |[m|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT, "File type specific")
|
||||
@Test
|
||||
fun testMethodMovingInNonJavaFile() {
|
||||
configureByJsonText("{\"foo\": \"${c}bar\"}\n")
|
||||
typeText(injector.parser.parseKeys("[m"))
|
||||
@ -668,6 +736,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-331 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testNonAsciiLettersInWord() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "Če${c}ská republika")
|
||||
assertOffset(6)
|
||||
@ -675,6 +744,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testHiraganaToPunctuation() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "は${c}はは!!!")
|
||||
assertOffset(3)
|
||||
@ -682,6 +752,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testHiraganaToFullWidthPunctuation() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "は${c}はは!!!")
|
||||
assertOffset(3)
|
||||
@ -689,6 +760,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testKatakanaToHiragana() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "チ${c}チチははは")
|
||||
assertOffset(3)
|
||||
@ -696,6 +768,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testKatakanaToHalfWidthKana() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "チ${c}チチウウウ")
|
||||
assertOffset(3)
|
||||
@ -703,6 +776,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testKatakanaToDigits() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "チ${c}チチ123")
|
||||
assertOffset(3)
|
||||
@ -710,6 +784,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testKatakanaToLetters() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "チ${c}チチ123")
|
||||
assertOffset(3)
|
||||
@ -717,6 +792,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testKatakanaToFullWidthLatin() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "チ${c}チチAAA")
|
||||
assertOffset(3)
|
||||
@ -724,6 +800,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testKatakanaToFullWidthDigits() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "チ${c}チチ333")
|
||||
assertOffset(3)
|
||||
@ -731,6 +808,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testHiraganaToKatakana() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "は${c}ははチチチ")
|
||||
assertOffset(3)
|
||||
@ -738,6 +816,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-58 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testHalftWidthKanaToLetters() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "ウウウAAA")
|
||||
assertOffset(3)
|
||||
@ -745,6 +824,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testCjkToPunctuation() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "测试${c}测试!!!")
|
||||
assertOffset(4)
|
||||
@ -752,6 +832,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testCjkToFullWidthPunctuation() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "测试${c}测试!!!")
|
||||
assertOffset(4)
|
||||
@ -759,6 +840,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testCjkToDigits() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "测试${c}测试123")
|
||||
assertOffset(4)
|
||||
@ -766,6 +848,7 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testCjkToFullWidthLatin() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "测试${c}测试AAA")
|
||||
assertOffset(4)
|
||||
@ -773,12 +856,14 @@ class MotionActionTest : VimTestCase() {
|
||||
|
||||
// |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testCjkToFullWidthDigits() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "测试${c}测试333")
|
||||
assertOffset(4)
|
||||
}
|
||||
|
||||
// |w|
|
||||
@Test
|
||||
fun testEmptyLineIsWord() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("w"),
|
||||
@ -793,6 +878,7 @@ class MotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |w|
|
||||
@Test
|
||||
fun testNotEmptyLineIsNotWord() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("w"),
|
||||
@ -806,23 +892,27 @@ two
|
||||
|
||||
// VIM-312 |w|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testLastWord() {
|
||||
typeTextInFile(injector.parser.parseKeys("w"), "${c}one\n")
|
||||
assertOffset(2)
|
||||
}
|
||||
|
||||
// |b|
|
||||
@Test
|
||||
fun testWordBackwardsAtFirstLineWithWhitespaceInFront() {
|
||||
typeTextInFile(injector.parser.parseKeys("b"), " ${c}x\n")
|
||||
assertOffset(0)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testRightToLastChar() {
|
||||
typeTextInFile(injector.parser.parseKeys("i<Right>"), "on${c}e\n")
|
||||
assertOffset(3)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDownToLastEmptyLine() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("j"),
|
||||
@ -837,6 +927,7 @@ two
|
||||
|
||||
// VIM-262 |c_CTRL-R|
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testSearchFromRegister() {
|
||||
VimPlugin.getRegister().setKeys('a', injector.parser.stringToKeys("two"))
|
||||
typeTextInFile(
|
||||
@ -852,6 +943,7 @@ two
|
||||
}
|
||||
|
||||
// |v_gv|
|
||||
@Test
|
||||
fun testSwapVisualSelections() {
|
||||
val keys = listOf("viw", "<Esc>", "0", "viw", "gv", "d")
|
||||
val before = "foo ${c}bar\n"
|
||||
@ -860,6 +952,7 @@ two
|
||||
}
|
||||
|
||||
// |CTRL-V|
|
||||
@Test
|
||||
fun testVisualBlockSelectionsDisplayedCorrectlyMovingRight() {
|
||||
val keys = listOf("<C-V>jl")
|
||||
val before = """
|
||||
@ -876,6 +969,7 @@ two
|
||||
}
|
||||
|
||||
// |CTRL-V|
|
||||
@Test
|
||||
fun testVisualBlockSelectionsDisplayedCorrectlyMovingLeft() {
|
||||
val keys = listOf("<C-V>jh")
|
||||
val before = """
|
||||
@ -892,6 +986,7 @@ two
|
||||
}
|
||||
|
||||
// |CTRL-V|
|
||||
@Test
|
||||
fun testVisualBlockSelectionsDisplayedCorrectlyInDollarMode() {
|
||||
val keys = listOf("<C-V>jj$")
|
||||
val before = """
|
||||
@ -910,6 +1005,7 @@ two
|
||||
}
|
||||
|
||||
// |v_o|
|
||||
@Test
|
||||
fun testSwapVisualSelectionEnds() {
|
||||
val keys = listOf("v", "l", "o", "l", "d")
|
||||
val before = "${c}foo\n"
|
||||
@ -918,6 +1014,7 @@ two
|
||||
}
|
||||
|
||||
// VIM-564 |g_|
|
||||
@Test
|
||||
fun testToLastNonBlankCharacterInLine() {
|
||||
doTest(
|
||||
"g_",
|
||||
@ -941,6 +1038,7 @@ two
|
||||
}
|
||||
|
||||
// |3g_|
|
||||
@Test
|
||||
fun testToLastNonBlankCharacterInLineWithCount3() {
|
||||
doTest(
|
||||
"3g_",
|
||||
@ -965,6 +1063,7 @@ two
|
||||
|
||||
// VIM-646 |gv|
|
||||
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testRestoreMultiLineSelectionAfterYank() {
|
||||
val keys = listOf("V", "j", "y", "G", "p", "gv", "d")
|
||||
val before = """
|
||||
@ -984,6 +1083,7 @@ two
|
||||
|
||||
// |v_>| |gv|
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT, "Complicated")
|
||||
@Test
|
||||
fun testRestoreMultiLineSelectionAfterIndent() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("V" + "2j"),
|
||||
@ -1035,6 +1135,7 @@ two
|
||||
}
|
||||
|
||||
// VIM-862 |gv|
|
||||
@Test
|
||||
fun testRestoreSelectionRange() {
|
||||
val keys = listOf("vl", "<Esc>", "gv")
|
||||
val before = """
|
||||
@ -1050,6 +1151,7 @@ two
|
||||
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testVisualLineSelectDown() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("Vj"),
|
||||
@ -1073,6 +1175,7 @@ two
|
||||
}
|
||||
|
||||
// VIM-784
|
||||
@Test
|
||||
fun testVisualLineSelectUp() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("Vk"),
|
||||
@ -1095,12 +1198,14 @@ two
|
||||
assertOffset(4)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test gv after backwards selection`() {
|
||||
configureByText("${c}Oh, hi Mark\n")
|
||||
typeText(parseKeys("yw" + "$" + "vb" + "p" + "gv"))
|
||||
assertSelection("Oh")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test gv after linewise selection`() {
|
||||
configureByText("${c}Oh, hi Mark\nOh, hi Markus\n")
|
||||
typeText(parseKeys("V" + "y" + "j" + "V" + "p" + "gv"))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,43 +11,56 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
// [VERSION UPDATE] 232+ enable tests
|
||||
@Suppress("unused")
|
||||
class ReformatCodeTest : VimTestCase() {
|
||||
@Test
|
||||
fun testMark() {
|
||||
assertTrue(true)
|
||||
kotlin.test.assertTrue(true)
|
||||
}
|
||||
|
||||
fun ignoretestEmpty() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testEmpty() {
|
||||
configureByJavaText("<caret>")
|
||||
typeText(injector.parser.parseKeys("gqq"))
|
||||
assertState("<caret>")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestWithCount() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testWithCount() {
|
||||
configureByJavaText("class C {\n\tint a;\n\tint <caret>b;\n\tint c;\n\tint d;\n}\n")
|
||||
typeText(injector.parser.parseKeys("2gqq"))
|
||||
assertState("class C {\n" + "\tint a;\n" + " <caret>int b;\n" + " int c;\n" + "\tint d;\n" + "}\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestWithUpMotion() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testWithUpMotion() {
|
||||
configureByJavaText("class C {\n" + "\tint a;\n" + "\tint b;\n" + "\tint <caret>c;\n" + "\tint d;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("gqk"))
|
||||
assertState("class C {\n" + "\tint a;\n" + " <caret>int b;\n" + " int c;\n" + "\tint d;\n" + "}\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestWithRightMotion() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testWithRightMotion() {
|
||||
configureByJavaText("class C {\n" + "\tint a;\n" + "\tint <caret>b;\n" + "\tint c;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("gql"))
|
||||
assertState("class C {\n" + "\tint a;\n" + " <caret>int b;\n" + "\tint c;\n" + "}\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestWithTextObject() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testWithTextObject() {
|
||||
configureByJavaText("class C {\n" + "\tint a;\n" + "\tint <caret>b;\n" + "\tint c;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("gqi{"))
|
||||
assertState(
|
||||
@ -61,35 +74,45 @@ class ReformatCodeTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestWithCountsAndDownMotion() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testWithCountsAndDownMotion() {
|
||||
configureByJavaText("class C {\n" + "\tint <caret>a;\n" + "\tint b;\n" + "\tint c;\n" + "\tint d;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("2gqj"))
|
||||
assertState("class C {\n" + " <caret>int a;\n" + " int b;\n" + " int c;\n" + "\tint d;\n" + "}\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestVisual() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testVisual() {
|
||||
configureByJavaText("class C {\n" + "\tint a;\n" + "\tint <caret>b;\n" + "\tint c;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("v" + "l" + "gq"))
|
||||
assertState("class C {\n" + "\tint a;\n" + " <caret>int b;\n" + "\tint c;\n" + "}\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestLinewiseVisual() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testLinewiseVisual() {
|
||||
configureByJavaText("class C {\n" + "\tint a;\n" + "\tint <caret>b;\n" + "\tint c;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("V" + "l" + "gq"))
|
||||
assertState("class C {\n" + "\tint a;\n" + " <caret>int b;\n" + "\tint c;\n" + "}\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestVisualMultiline() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testVisualMultiline() {
|
||||
configureByJavaText("class C {\n" + "\tint a;\n" + "\tint <caret>b;\n" + "\tint c;\n" + "\tint d;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("v" + "j" + "gq"))
|
||||
assertState("class C {\n" + "\tint a;\n" + " <caret>int b;\n" + " int c;\n" + "\tint d;\n" + "}\n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
fun ignoretestVisualBlock() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testVisualBlock() {
|
||||
configureByJavaText("class C {\n" + "\tint a;\n" + "\tint <caret>b;\n" + "\tint c;\n" + "\tint d;\n" + "}\n")
|
||||
typeText(injector.parser.parseKeys("<C-V>" + "j" + "gq"))
|
||||
assertState("class C {\n" + "\tint a;\n" + " <caret>int b;\n" + " int c;\n" + "\tint d;\n" + "}\n")
|
||||
|
@ -12,7 +12,7 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class RepeatActionTest : VimTestCase() {
|
||||
|
||||
@ -41,8 +41,8 @@ class RepeatActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1644
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testRepeatChangeInVisualMode() {
|
||||
configureByText("foobar foobar")
|
||||
typeText(injector.parser.parseKeys("<C-V>llc" + "fu" + "<Esc>" + "w" + "."))
|
||||
@ -50,8 +50,8 @@ class RepeatActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1644
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testRepeatChangeInVisualModeMultiline() {
|
||||
configureByText(
|
||||
"There is a red house.\n" +
|
||||
|
@ -13,128 +13,148 @@ 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.MappingOwner
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ResetModeActionTest : VimTestCase() {
|
||||
private val owner = MappingOwner.Plugin.get("ResetModeActionTest")
|
||||
|
||||
@Test
|
||||
fun `test reset from normal mode`() {
|
||||
val keys = "<C-\\><C-N>"
|
||||
val before = "A Discovery"
|
||||
val after = "A Discovery"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset from insert mode`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset from insert mode check position`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset and execute command`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset from visual mode`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset from select mode`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset from operator-pending mode`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset from operator-pending mode with delete`() {
|
||||
val keys = "d<Esc>dw"
|
||||
val before = "A Discovery"
|
||||
val after = "Discovery"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete command after resetting operator-pending mode`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete command after resetting operator-pending mode with esc`() {
|
||||
val keys = listOf("d", "<Esc>", "dw")
|
||||
val before = "A Discovery"
|
||||
val after = "Discovery"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
|
||||
@Test
|
||||
fun `test delete command after resetting operator-pending mode with ctrl open bracket`() {
|
||||
val keys = listOf("d", "<C-[>", "dw")
|
||||
val before = "A Discovery"
|
||||
val after = "Discovery"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.MAPPING)
|
||||
@Test
|
||||
fun `test delete command after resetting operator-pending mode with mapping`() {
|
||||
VimPlugin.getKey()
|
||||
.putKeyMapping(MappingMode.NVO, injector.parser.parseKeys("<C-D>"), owner, injector.parser.parseKeys("<Esc>"), false)
|
||||
.putKeyMapping(
|
||||
MappingMode.NVO,
|
||||
injector.parser.parseKeys("<C-D>"),
|
||||
owner,
|
||||
injector.parser.parseKeys("<Esc>"),
|
||||
false
|
||||
)
|
||||
|
||||
val keys = listOf("d", "<C-D>", "dw")
|
||||
val before = "A Discovery"
|
||||
val after = "Discovery"
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test non-delete commands after resetting operator-pending mode`() {
|
||||
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)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete after escaping t`() {
|
||||
val keys = "dt<esc>D"
|
||||
val before = "A ${c}Discovery"
|
||||
val after = "A "
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
TestCase.assertFalse(myFixture.editor.selectionModel.hasSelection())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,16 @@ import com.maddyhome.idea.vim.register.RegisterConstants.LAST_SEARCH_REGISTER
|
||||
import com.maddyhome.idea.vim.register.RegisterConstants.SMALL_DELETION_REGISTER
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.Assert
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class SpecialRegistersTest : VimTestCase() {
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
@BeforeEach
|
||||
override fun setUp(testInfo: TestInfo) {
|
||||
super.setUp(testInfo)
|
||||
val registerGroup = VimPlugin.getRegister()
|
||||
registerGroup.setKeys('a', injector.parser.stringToKeys(DUMMY_TEXT))
|
||||
registerGroup.setKeys(SMALL_DELETION_REGISTER, injector.parser.stringToKeys(DUMMY_TEXT))
|
||||
@ -32,14 +37,16 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-581
|
||||
@Test
|
||||
fun testSmallDelete() {
|
||||
typeTextInFile(injector.parser.parseKeys("de"), "one <caret>two three\n")
|
||||
assertEquals("two", getRegisterText(SMALL_DELETION_REGISTER))
|
||||
kotlin.test.assertEquals("two", getRegisterText(SMALL_DELETION_REGISTER))
|
||||
// Text smaller than line doesn't go to numbered registers (except special cases)
|
||||
assertRegisterNotChanged('1')
|
||||
}
|
||||
|
||||
// |d| |%| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteWithPercent() {
|
||||
typeTextInFile(injector.parser.parseKeys("d%"), "(one<caret> two) three\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -47,6 +54,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |(| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteTillPrevSentence() {
|
||||
typeTextInFile(injector.parser.parseKeys("d("), "One. Two<caret>. Three.\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -54,6 +62,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |)| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteTillNextSentence() {
|
||||
typeTextInFile(injector.parser.parseKeys("d)"), "One. <caret>Two. Three.\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -61,6 +70,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |`| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteWithMark() {
|
||||
typeTextInFile(injector.parser.parseKeys("ma" + "b" + "d`a"), "one two<caret> three\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -68,6 +78,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |/| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteWithSearch() {
|
||||
typeTextInFile(injector.parser.parseKeys("d/" + "o" + "<Enter>"), "one <caret>two three\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -75,6 +86,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |?| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteWithBackSearch() {
|
||||
typeTextInFile(injector.parser.parseKeys("d?" + "t" + "<Enter>"), "one two<caret> three\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -82,6 +94,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |n| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteWithSearchRepeat() {
|
||||
typeTextInFile(injector.parser.parseKeys("/" + "t" + "<Enter>" + "dn"), "<caret>one two three\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -89,6 +102,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |N| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteWithBackSearchRepeat() {
|
||||
typeTextInFile(injector.parser.parseKeys("/" + "t" + "<Enter>" + "dN"), "one tw<caret>o three\n")
|
||||
assertRegisterChanged('1')
|
||||
@ -96,6 +110,7 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |{| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteTillPrevParagraph() {
|
||||
typeTextInFile(injector.parser.parseKeys("d{"), "one<caret> two three")
|
||||
assertRegisterChanged('1')
|
||||
@ -103,12 +118,14 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |d| |}| Special case for small delete
|
||||
@Test
|
||||
fun testSmallDeleteTillNextParagraph() {
|
||||
typeTextInFile(injector.parser.parseKeys("d}"), "one<caret> two three")
|
||||
assertRegisterChanged('1')
|
||||
assertRegisterChanged(SMALL_DELETION_REGISTER)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSmallDeleteInRegister() {
|
||||
typeTextInFile(injector.parser.parseKeys("\"ade"), "one <caret>two three\n")
|
||||
|
||||
@ -118,58 +135,66 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
assertRegisterNotChanged(SMALL_DELETION_REGISTER)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLineDelete() {
|
||||
typeTextInFile(injector.parser.parseKeys("dd"), "one <caret>two three\n")
|
||||
assertRegisterChanged('1')
|
||||
assertRegisterNotChanged(SMALL_DELETION_REGISTER)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLineDeleteInRegister() {
|
||||
typeTextInFile(injector.parser.parseKeys("\"add"), "one <caret>two three\n")
|
||||
assertRegisterChanged('a')
|
||||
assertRegisterNotChanged('1')
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNumberedRegistersShifting() {
|
||||
configureByText("<caret>one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
|
||||
typeText(injector.parser.parseKeys("dd" + "dd"))
|
||||
assertEquals("one\n", getRegisterText('2'))
|
||||
assertEquals("two\n", getRegisterText('1'))
|
||||
kotlin.test.assertEquals("one\n", getRegisterText('2'))
|
||||
kotlin.test.assertEquals("two\n", getRegisterText('1'))
|
||||
typeText(injector.parser.parseKeys("dd" + "dd" + "dd"))
|
||||
assertEquals("one\n", getRegisterText('5'))
|
||||
assertEquals("four\n", getRegisterText('2'))
|
||||
kotlin.test.assertEquals("one\n", getRegisterText('5'))
|
||||
kotlin.test.assertEquals("four\n", getRegisterText('2'))
|
||||
typeText(injector.parser.parseKeys("dd" + "dd" + "dd" + "dd"))
|
||||
assertEquals("one\n", getRegisterText('9'))
|
||||
kotlin.test.assertEquals("one\n", getRegisterText('9'))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSearchRegisterAfterSearch() {
|
||||
configureByText("<caret>one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
|
||||
enterSearch("three", true)
|
||||
assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
kotlin.test.assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSearchRegisterAfterSubstitute() {
|
||||
configureByText("<caret>one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
|
||||
enterCommand("%s/three/3/g")
|
||||
assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
kotlin.test.assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSearchRegisterAfterSearchRange() {
|
||||
configureByText("<caret>one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
|
||||
enterCommand("/three/d")
|
||||
assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
kotlin.test.assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSearchRegisterAfterMultipleSearchRanges() {
|
||||
configureByText("<caret>one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
|
||||
enterCommand("/one/;/three/d")
|
||||
assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
kotlin.test.assertEquals("three", getRegisterText(LAST_SEARCH_REGISTER))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLastInsertedTextRegister() {
|
||||
configureByText("<caret>")
|
||||
typeText(injector.parser.parseKeys("i" + "abc" + "<Esc>"))
|
||||
assertEquals("abc", getRegisterText('.'))
|
||||
kotlin.test.assertEquals("abc", getRegisterText('.'))
|
||||
assertRegisterChanged(LAST_INSERTED_TEXT_REGISTER)
|
||||
}
|
||||
|
||||
@ -180,13 +205,13 @@ class SpecialRegistersTest : VimTestCase() {
|
||||
|
||||
private fun assertRegisterNotChanged(registerName: Char) {
|
||||
val registerText = getRegisterText(registerName)
|
||||
assertEquals(DUMMY_TEXT, registerText)
|
||||
kotlin.test.assertEquals(DUMMY_TEXT, registerText)
|
||||
}
|
||||
|
||||
private fun getRegisterText(registerName: Char): String? {
|
||||
val registerGroup = VimPlugin.getRegister()
|
||||
val register = registerGroup.getRegister(registerName)
|
||||
assertNotNull(register)
|
||||
assertNotNull<Any>(register)
|
||||
return register!!.text
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,10 @@ import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class RepeatChangeActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test simple repeat`() {
|
||||
val keys = listOf("v2erXj^", ".")
|
||||
val before = """
|
||||
@ -36,6 +38,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test simple repeat with dollar motion`() {
|
||||
val keys = listOf("v\$rXj^", ".")
|
||||
val before = """
|
||||
@ -57,6 +60,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test repeat to line end`() {
|
||||
val keys = listOf("v2erXj\$b", ".")
|
||||
val before = """
|
||||
@ -79,6 +83,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(description = "Different caret position")
|
||||
@Test
|
||||
fun `test repeat multiline`() {
|
||||
val keys = listOf("vjlrXj", ".")
|
||||
val before = """
|
||||
@ -100,6 +105,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test count doesn't affect repeat`() {
|
||||
val keys = listOf("v2erXj^", "10.")
|
||||
val before = """
|
||||
@ -121,6 +127,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test multicaret`() {
|
||||
val keys = listOf("v2erXj^", ".")
|
||||
val before = """
|
||||
@ -142,6 +149,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test line motion`() {
|
||||
val keys = listOf("VrXj^", ".")
|
||||
val before = """
|
||||
@ -164,6 +172,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(description = "Wrong caret position")
|
||||
@Test
|
||||
fun `test line motion to end`() {
|
||||
val keys = listOf("VjrX2j^", ".")
|
||||
val before = """
|
||||
@ -186,6 +195,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(description = "Wrong caret position")
|
||||
@Test
|
||||
fun `test line motion shift`() {
|
||||
val keys = listOf("V3j<", ".")
|
||||
val before = """
|
||||
@ -208,6 +218,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(description = "Wrong caret position")
|
||||
@Test
|
||||
fun `test block motion`() {
|
||||
val keys = listOf("<C-V>jerXll", ".")
|
||||
val before = """
|
||||
@ -240,6 +251,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
fun `test block motion to end`() {
|
||||
val keys = listOf("<C-V>jjerXjl", ".")
|
||||
val before = """
|
||||
@ -264,6 +276,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun `test block with dollar motion`() {
|
||||
val keys = listOf("<C-V>j\$rXj^", ".")
|
||||
val before = """
|
||||
@ -285,6 +298,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test repeat with count`() {
|
||||
val keys = listOf("4x", "j", ".")
|
||||
val before = """
|
||||
@ -314,6 +328,7 @@ class RepeatChangeActionTest : VimTestCase() {
|
||||
One
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
fun `test redo register feature`() {
|
||||
doTest(
|
||||
listOf("dd", "dd", "dd", "\"1p", ".", "."),
|
||||
|
@ -11,8 +11,10 @@ package org.jetbrains.plugins.ideavim.action.change
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.group.IjOptionConstants
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class UndoActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test simple undo`() {
|
||||
val keys = listOf("dw", "u")
|
||||
val before = """
|
||||
@ -25,8 +27,8 @@ class UndoActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
val after = before
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
val editor = myFixture.editor
|
||||
assertFalse(editor.caretModel.primaryCaret.hasSelection())
|
||||
val editor = fixture.editor
|
||||
kotlin.test.assertFalse(editor.caretModel.primaryCaret.hasSelection())
|
||||
}
|
||||
|
||||
// Not yet supported
|
||||
@ -42,9 +44,10 @@ class UndoActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
val after = before
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
assertFalse(hasSelection())
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test undo with count`() {
|
||||
val keys = listOf("dwdwdw", "2u")
|
||||
val before = """
|
||||
@ -64,9 +67,10 @@ class UndoActionTest : VimTestCase() {
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
assertFalse(hasSelection())
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test cursor movements do not require additional undo`() {
|
||||
if (!optionsNoEditor().isSet(IjOptionConstants.oldundo)) {
|
||||
val keys = listOf("a1<Esc>ea2<Esc>ea3<Esc>", "uu")
|
||||
@ -87,12 +91,12 @@ class UndoActionTest : VimTestCase() {
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
assertFalse(hasSelection())
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasSelection(): Boolean {
|
||||
val editor = myFixture.editor
|
||||
val editor = fixture.editor
|
||||
return editor.caretModel.primaryCaret.hasSelection()
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.change.change
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeCaseToggleCharacterActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("~"),
|
||||
@ -29,6 +31,7 @@ class ChangeCaseToggleCharacterActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap at file end`() {
|
||||
doTest(
|
||||
listOf("~"),
|
||||
@ -44,6 +47,7 @@ class ChangeCaseToggleCharacterActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap to next line`() {
|
||||
doTest(
|
||||
listOf("~"),
|
||||
@ -61,6 +65,7 @@ class ChangeCaseToggleCharacterActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("~"),
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.change.change
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeLineActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test on empty file`() {
|
||||
setupChecks {
|
||||
this.neoVim.ignoredRegisters = setOf('1', '"')
|
||||
@ -19,6 +21,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
doTest("cc", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on empty file with S`() {
|
||||
setupChecks {
|
||||
this.neoVim.ignoredRegisters = setOf('1', '"')
|
||||
@ -26,6 +29,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
doTest("S", "", "", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on last line with S`() {
|
||||
doTest(
|
||||
"S",
|
||||
@ -42,6 +46,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on last line with new line with S`() {
|
||||
doTest(
|
||||
"S",
|
||||
@ -60,6 +65,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on very last line with new line with S`() {
|
||||
doTest(
|
||||
"S",
|
||||
@ -76,6 +82,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on very last line with new line with S2`() {
|
||||
doTest(
|
||||
"S",
|
||||
@ -94,6 +101,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on first line with new line with S`() {
|
||||
doTest(
|
||||
"S",
|
||||
@ -110,6 +118,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on last line with new line with cc`() {
|
||||
doTest(
|
||||
"cc",
|
||||
@ -128,6 +137,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on last line`() {
|
||||
doTest(
|
||||
"cc",
|
||||
@ -146,6 +156,7 @@ class ChangeLineActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test S with count`() {
|
||||
doTest(
|
||||
"3S",
|
||||
|
@ -12,19 +12,24 @@ package org.jetbrains.plugins.ideavim.action.change.change
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeMotionActionTest : VimTestCase() {
|
||||
// VIM-515 |c| |W|
|
||||
@Test
|
||||
fun `test change big word with punctuation and alpha`() {
|
||||
doTest("cW", "foo${c}(bar baz\n", "foo baz\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-300 |c| |w|
|
||||
@Test
|
||||
fun testChangeWordTwoWordsWithoutWhitespace() {
|
||||
doTest("cw", "${c}\$value\n", "value\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
// VIM-296 |cc|
|
||||
@Test
|
||||
fun testChangeLineAtLastLine() {
|
||||
doTest(
|
||||
"cc",
|
||||
@ -36,6 +41,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-296 |cc|
|
||||
@Test
|
||||
fun testChangeLineWithIndent() {
|
||||
doTest(
|
||||
"cc",
|
||||
@ -55,6 +61,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-536 |cc|
|
||||
@Test
|
||||
fun testChangeLineAtSecondLastLine() {
|
||||
doTest(
|
||||
"ccbaz",
|
||||
@ -65,6 +72,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeLineAtLastLineWithUnderscoreMotion() {
|
||||
doTest(
|
||||
"c_",
|
||||
@ -83,6 +91,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeLineAtSecondLastLineWithUnderscoreMotion() {
|
||||
doTest(
|
||||
"c_baz",
|
||||
@ -94,6 +103,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-200 |c| |w|
|
||||
@Test
|
||||
fun testChangeWordAtLastChar() {
|
||||
doTest(
|
||||
"cw",
|
||||
@ -105,6 +115,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-1380 |c| |w| |count|
|
||||
@Test
|
||||
fun testChangeTwoWordsAtLastChar() {
|
||||
doTest(
|
||||
"c2w",
|
||||
@ -116,6 +127,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// |c| |t|
|
||||
@Test
|
||||
fun testChangeLinesTillForwards() {
|
||||
doTest(
|
||||
listOf("ct(", "for "),
|
||||
@ -135,6 +147,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-276 |c| |T|
|
||||
@Test
|
||||
fun testChangeLinesTillBackwards() {
|
||||
doTest(
|
||||
"cT(",
|
||||
@ -147,7 +160,9 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
|
||||
// VIM-276 |c| |F|
|
||||
@Suppress("unused")
|
||||
fun ignoreTestChangeLinesToBackwards() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun testChangeLinesToBackwards() {
|
||||
doTest(
|
||||
"cFc",
|
||||
"if (condition) {${c}\n" + "}\n",
|
||||
@ -158,6 +173,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-421 |c| |w|
|
||||
@Test
|
||||
fun testChangeLastWordInLine() {
|
||||
doTest(
|
||||
"cw",
|
||||
@ -169,6 +185,7 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-421 |c| |iw|
|
||||
@Test
|
||||
fun testChangeLastInnerWordInLine() {
|
||||
doTest(
|
||||
listOf("c", "iw", "baz"),
|
||||
@ -180,10 +197,12 @@ class ChangeMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-421 |c| |w|
|
||||
@Test
|
||||
fun testChangeLastCharInLine() {
|
||||
doTest("cw", "fo${c}o\n", "fo${c}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLastSymbolInWord() {
|
||||
doTest("cw", "fo${c}o", "fo${c}", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
@ -14,8 +14,10 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeVisualActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test multiple line change`() {
|
||||
val keys = "VjcHello<esc>"
|
||||
val before = """
|
||||
@ -36,6 +38,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test multiple line change in text middle`() {
|
||||
val keys = "Vjc"
|
||||
val before = """
|
||||
@ -66,6 +69,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
${c}
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
fun `test multiple line change till the end`() {
|
||||
val keys = "Vjc"
|
||||
val before = """
|
||||
@ -88,6 +92,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test multiple line change till the end with two new lines`() {
|
||||
val keys = "Vjc"
|
||||
val before = """
|
||||
@ -115,6 +120,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(description = "Wrong caret position")
|
||||
@Test
|
||||
fun `test change with dollar motion`() {
|
||||
val keys = listOf("<C-V>3j$", "c", "Hello<Esc>")
|
||||
val before = """
|
||||
@ -136,6 +142,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test replace first line`() {
|
||||
val keys = "VcHello<esc>"
|
||||
val before = "${c}A Discovery"
|
||||
@ -143,6 +150,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test change visual action`() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("v2lc" + "aaa" + "<ESC>"),
|
||||
@ -154,6 +162,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
|
||||
// VIM-1379 |CTRL-V| |j| |v_b_c|
|
||||
@VimBehaviorDiffers(description = "Different caret position")
|
||||
@Test
|
||||
fun `test change visual block with empty line in the middle`() {
|
||||
doTest(
|
||||
listOf("ll", "<C-V>", "ljjc", "_quux_", "<Esc>"),
|
||||
@ -176,6 +185,7 @@ class ChangeVisualActionTest : VimTestCase() {
|
||||
|
||||
// VIM-1379 |CTRL-V| |j| |v_b_c|
|
||||
@VimBehaviorDiffers(description = "Different caret position")
|
||||
@Test
|
||||
fun `test change visual block with shorter line in the middle`() {
|
||||
doTest(
|
||||
listOf("ll", "<C-V>", "ljjc", "_quux_", "<Esc>"),
|
||||
|
@ -13,8 +13,10 @@ package org.jetbrains.plugins.ideavim.action.change.change
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeVisualLinesEndActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test change last line`() {
|
||||
val keys = "VC"
|
||||
val before = """
|
||||
@ -36,6 +38,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test last empty line`() {
|
||||
val keys = "vC"
|
||||
val before = """
|
||||
@ -69,6 +72,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
|
||||
${c}
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
fun `test change last two lines`() {
|
||||
val keys = "vjC"
|
||||
val before = """
|
||||
|
@ -8,29 +8,36 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.change
|
||||
|
||||
// class InsertRegisterTest : VimTestCase() {
|
||||
// todo test cursor position VIM-2732
|
||||
// fun `test multiline insert from expression register`() {
|
||||
// val keys = "VjyGo<C-r>=@\"<CR>"
|
||||
// val before = """
|
||||
// A Discovery
|
||||
//
|
||||
// ${c}I found it in a legendary land
|
||||
// all rocks and lavender and tufted grass,
|
||||
// where it was settled on some sodden sand
|
||||
// hard by the torrent of a mountain pass.
|
||||
// """.trimIndent()
|
||||
// val after = """
|
||||
// A Discovery
|
||||
//
|
||||
// I found it in a legendary land
|
||||
// all rocks and lavender and tufted grass,
|
||||
// where it was settled on some sodden sand
|
||||
// hard by the torrent of a mountain pass.
|
||||
// I found it in a legendary land
|
||||
// all rocks and lavender and tufted grass,
|
||||
// ${c}
|
||||
// """.trimIndent()
|
||||
// doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
// }
|
||||
// }
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertRegisterTest : VimTestCase() {
|
||||
// todo test cursor position VIM-2732
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test multiline insert from expression register`() {
|
||||
val keys = "VjyGo<C-r>=@\"<CR>"
|
||||
val before = """
|
||||
A Discovery
|
||||
|
||||
${c}I found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
val after = """
|
||||
A Discovery
|
||||
|
||||
I found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
I found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
${c}
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
}
|
||||
|
@ -10,16 +10,20 @@ package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeNumberDecActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test decrement hex to negative value`() {
|
||||
doTest("<C-X>", "0x0000", "0xffffffffffffffff", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test decrement hex to negative value by 10`() {
|
||||
doTest("10<C-X>", "0x0005", "0xfffffffffffffffb", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test decrement oct to negative value`() {
|
||||
doTest(
|
||||
":set nrformats+=octal<CR><C-X>",
|
||||
@ -30,10 +34,12 @@ class ChangeNumberDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test decrement incorrect octal`() {
|
||||
doTest(":set nrformats+=octal<CR><C-X>", "008", "7", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test decrement oct to negative value by 10`() {
|
||||
doTest(
|
||||
":set nrformats+=octal<CR>10<C-X>",
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ChangeNumberIncActionTest : VimTestCase() {
|
||||
@VimBehaviorDiffers(originalVimAfter = "11X0")
|
||||
@Test
|
||||
fun `test inc fancy number`() {
|
||||
doTest("<C-A>", "1${c}0X0", "10X1", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
@ -10,11 +10,13 @@ package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test dec visual avalanche`() {
|
||||
doTest(
|
||||
"VGg<C-X>",
|
||||
@ -33,6 +35,7 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dec visual avalanche multiple times`() {
|
||||
doTest(
|
||||
"VG2g<C-X>",
|
||||
|
@ -10,11 +10,13 @@ package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test inc visual avalanche`() {
|
||||
doTest(
|
||||
"VGg<C-A>",
|
||||
@ -33,6 +35,7 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test inc visual avalanche multiple times`() {
|
||||
doTest(
|
||||
"VG2g<C-A>",
|
||||
|
@ -11,11 +11,13 @@ package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class ChangeVisualNumberDecActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test dec visual full number`() {
|
||||
doTest(
|
||||
"V<C-X>",
|
||||
@ -26,6 +28,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dec visual multiple numbers`() {
|
||||
doTest(
|
||||
"v10w<C-X>",
|
||||
@ -36,6 +39,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dec visual part of number`() {
|
||||
doTest(
|
||||
"v4l<C-X>",
|
||||
@ -46,6 +50,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dec visual multiple lines`() {
|
||||
doTest(
|
||||
"V2j<C-X>",
|
||||
@ -74,6 +79,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dec visual 1000 multiple lines`() {
|
||||
doTest(
|
||||
"V2j<C-X>",
|
||||
@ -92,6 +98,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dec visual multiple numbers on line`() {
|
||||
doTest(
|
||||
"V<C-X>",
|
||||
@ -102,6 +109,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test change number dec visual action`() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("Vj<C-X>"),
|
||||
|
@ -11,11 +11,13 @@ package org.jetbrains.plugins.ideavim.action.change.change.number
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test inc visual full number`() {
|
||||
doTest(
|
||||
"V<C-A>",
|
||||
@ -26,6 +28,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test inc visual multiple numbers`() {
|
||||
doTest(
|
||||
"v10w<C-A>",
|
||||
@ -36,6 +39,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test inc visual part of number`() {
|
||||
doTest(
|
||||
"v4l<C-A>",
|
||||
@ -46,6 +50,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test inc visual multiple lines`() {
|
||||
doTest(
|
||||
"V2j<C-A>",
|
||||
@ -74,6 +79,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test inc visual 999 multiple lines`() {
|
||||
doTest(
|
||||
"V2j<C-A>",
|
||||
@ -92,6 +98,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test inc visual multiple numbers on line`() {
|
||||
doTest(
|
||||
"V<C-A>",
|
||||
@ -102,6 +109,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test change number inc visual multiple cursor`() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("Vj<C-A>"),
|
||||
@ -124,6 +132,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test two numbers on the same line`() {
|
||||
doTest(
|
||||
"v$<C-A>",
|
||||
@ -134,6 +143,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test two numbers on the same line with two lines`() {
|
||||
doTest(
|
||||
"vj<C-A>",
|
||||
@ -148,6 +158,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test two numbers on the same line with three lines`() {
|
||||
doTest(
|
||||
"vjj<C-A>",
|
||||
@ -164,6 +175,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test block nothing increment`() {
|
||||
doTest(
|
||||
"<C-V>jjll<C-A>",
|
||||
@ -182,6 +194,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test block increment end`() {
|
||||
doTest(
|
||||
"<C-V>jj$<C-A>",
|
||||
|
@ -9,9 +9,11 @@
|
||||
package org.jetbrains.plugins.ideavim.action.change.delete
|
||||
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
// |X|
|
||||
class DeleteCharacterLeftActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test delete single character`() {
|
||||
val keys = "X"
|
||||
val before = "I f${c}ound it in a legendary land"
|
||||
@ -21,6 +23,7 @@ class DeleteCharacterLeftActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete multiple characters`() {
|
||||
val keys = "5X"
|
||||
val before = "I found$c it in a legendary land"
|
||||
@ -30,6 +33,7 @@ class DeleteCharacterLeftActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test deletes min of count and start of line`() {
|
||||
val keys = "25X"
|
||||
val before = """
|
||||
@ -53,6 +57,7 @@ class DeleteCharacterLeftActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete with inlay relating to preceding text`() {
|
||||
val keys = "X"
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
@ -78,6 +83,7 @@ class DeleteCharacterLeftActionTest : VimTestCase() {
|
||||
assertVisualPosition(0, 4)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete with inlay relating to following text`() {
|
||||
// This should have the same behaviour as related to preceding text
|
||||
val keys = "X"
|
||||
@ -103,6 +109,7 @@ class DeleteCharacterLeftActionTest : VimTestCase() {
|
||||
assertVisualPosition(0, 4)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test deleting characters scrolls caret into view`() {
|
||||
configureByText("Hello world".repeat(200))
|
||||
enterCommand("set sidescrolloff=5")
|
||||
|
@ -10,9 +10,11 @@ package org.jetbrains.plugins.ideavim.action.change.delete
|
||||
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
// |x|
|
||||
class DeleteCharacterRightActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test delete single character`() {
|
||||
val keys = injector.parser.parseKeys("x")
|
||||
val before = "I ${c}found it in a legendary land"
|
||||
@ -22,6 +24,7 @@ class DeleteCharacterRightActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete multiple characters`() {
|
||||
val keys = injector.parser.parseKeys("5x")
|
||||
val before = "I ${c}found it in a legendary land"
|
||||
@ -31,6 +34,7 @@ class DeleteCharacterRightActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test deletes min of count and end of line`() {
|
||||
val keys = injector.parser.parseKeys("20x")
|
||||
val before = """
|
||||
@ -54,6 +58,7 @@ class DeleteCharacterRightActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete with inlay relating to preceding text`() {
|
||||
val keys = injector.parser.parseKeys("x")
|
||||
val before = "I f${c}ound it in a legendary land"
|
||||
@ -81,6 +86,7 @@ class DeleteCharacterRightActionTest : VimTestCase() {
|
||||
assertVisualPosition(0, 4)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete with inlay relating to following text`() {
|
||||
// This should have the same behaviour as related to preceding text
|
||||
val keys = injector.parser.parseKeys("x")
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.change.delete
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DeleteEndOfLineActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test delete on empty line`() {
|
||||
doTest(
|
||||
"D",
|
||||
|
@ -16,9 +16,11 @@ import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjOptionConstants.ideajoin) {
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideajoin, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test join with idea`() {
|
||||
doTest(
|
||||
"J",
|
||||
@ -43,6 +45,7 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjOptionConstants.idea
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideajoin, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test join with idea with count`() {
|
||||
doTest(
|
||||
"3J",
|
||||
@ -67,6 +70,7 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjOptionConstants.idea
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideajoin, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test join with idea with large count`() {
|
||||
doTest(
|
||||
"10J",
|
||||
|
@ -16,10 +16,12 @@ import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DeleteJoinVisualLinesSpacesActionTest : VimOptionTestCase(IjOptionConstants.ideajoin) {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideajoin, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test join via idea`() {
|
||||
doTest(
|
||||
"VjJ",
|
||||
|
@ -15,9 +15,11 @@ import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DeleteMotionActionTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test delete last line`() {
|
||||
typeTextInFile(
|
||||
"dd",
|
||||
@ -35,6 +37,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test on line in middle`() {
|
||||
typeTextInFile(
|
||||
"dd",
|
||||
@ -52,6 +55,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete single line`() {
|
||||
typeTextInFile(
|
||||
"dd",
|
||||
@ -63,6 +67,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test delete last line with nostartofline`() {
|
||||
configureByText(
|
||||
"""
|
||||
@ -82,6 +87,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(originalVimAfter = " expression two\n")
|
||||
@Test
|
||||
fun `test delete last line stored with new line`() {
|
||||
typeTextInFile(
|
||||
"dd",
|
||||
@ -92,9 +98,10 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
""".trimIndent(),
|
||||
)
|
||||
val savedText = VimPlugin.getRegister().lastRegister?.text ?: ""
|
||||
assertEquals(" expression two\n", savedText)
|
||||
kotlin.test.assertEquals(" expression two\n", savedText)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete line action multicaret`() {
|
||||
typeTextInFile(
|
||||
"d3d",
|
||||
@ -112,6 +119,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
assertState("${c}abcde\n${c}")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete motion action multicaret`() {
|
||||
typeTextInFile(
|
||||
"dt)",
|
||||
@ -144,6 +152,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete empty line`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -164,6 +173,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
assertState(newFile)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete on last line`() {
|
||||
doTest(
|
||||
"dd",
|
||||
@ -183,6 +193,7 @@ class DeleteMotionActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test empty line`() {
|
||||
doTest(
|
||||
"dd",
|
||||
|
@ -15,11 +15,13 @@ import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.jetbrains.plugins.ideavim.waitAndAssertMode
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class DeleteVisualActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test delete block SE direction`() {
|
||||
val keys = listOf("<C-V>e2j", "d")
|
||||
val before = """
|
||||
@ -41,6 +43,7 @@ class DeleteVisualActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete block SW direction`() {
|
||||
val keys = listOf("<C-V>b2j", "d")
|
||||
val before = """
|
||||
@ -62,6 +65,7 @@ class DeleteVisualActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete block NW direction`() {
|
||||
val keys = listOf("<C-V>b2k", "d")
|
||||
val before = """
|
||||
@ -83,6 +87,7 @@ class DeleteVisualActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete block NE direction`() {
|
||||
val keys = listOf("<C-V>2e2k", "d")
|
||||
val before = """
|
||||
@ -105,6 +110,7 @@ class DeleteVisualActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test delete after extend selection`() {
|
||||
// This test emulates deletion after structural selection
|
||||
// In short, when caret is not on the selection end
|
||||
@ -118,8 +124,8 @@ class DeleteVisualActionTest : VimTestCase() {
|
||||
${se}hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
)
|
||||
IdeaSelectionControl.controlNonVimSelectionChange(myFixture.editor)
|
||||
waitAndAssertMode(myFixture, VimStateMachine.Mode.VISUAL)
|
||||
IdeaSelectionControl.controlNonVimSelectionChange(fixture.editor)
|
||||
waitAndAssertMode(fixture, VimStateMachine.Mode.VISUAL)
|
||||
typeText(injector.parser.parseKeys("d"))
|
||||
assertState(
|
||||
"""
|
||||
@ -131,6 +137,7 @@ class DeleteVisualActionTest : VimTestCase() {
|
||||
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test delete with dollar motion`() {
|
||||
val keys = listOf("<C-V>3j$", "d")
|
||||
val before = """
|
||||
|
@ -12,8 +12,10 @@ package org.jetbrains.plugins.ideavim.action.change.delete
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DeleteVisualLinesActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test remove line in char visual mode`() {
|
||||
doTest(
|
||||
"vlllX",
|
||||
@ -33,6 +35,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test remove line in char visual mode last line`() {
|
||||
doTest(
|
||||
"vlllX",
|
||||
@ -52,6 +55,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test remove line in line visual mode`() {
|
||||
doTest(
|
||||
"VX",
|
||||
@ -71,6 +75,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test remove line in line visual mode line end`() {
|
||||
doTest(
|
||||
"VX",
|
||||
@ -90,6 +95,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test multiple line delete till the end`() {
|
||||
val keys = "Vjd"
|
||||
val before = """
|
||||
@ -111,6 +117,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test multiple line delete till the end with a new line`() {
|
||||
val keys = "Vjd"
|
||||
val before = """
|
||||
|
@ -19,9 +19,11 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -44,6 +46,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.virtualedit, OptionValueType.STRING, OptionConstants.virtualedit_onemore))
|
||||
@Test
|
||||
fun `test virtual edit delete middle to end`() {
|
||||
doTest(
|
||||
"D",
|
||||
@ -62,6 +65,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.virtualedit, OptionValueType.STRING, OptionConstants.virtualedit_onemore))
|
||||
@Test
|
||||
fun `test virtual edit delete end to end`() {
|
||||
doTest(
|
||||
"D",
|
||||
@ -80,6 +84,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.virtualedit, OptionValueType.STRING, OptionConstants.virtualedit_onemore))
|
||||
@Test
|
||||
fun `test virtual edit delete to end from virtual space`() {
|
||||
doTest(
|
||||
"D",
|
||||
@ -97,6 +102,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion with indent`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -119,6 +125,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test simple deletion with indent and nostartofline`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -142,6 +149,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion empty line`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -163,6 +171,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion last line`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -186,6 +195,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion first line`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -207,6 +217,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion before empty`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -230,6 +241,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion last line without empty line`() {
|
||||
val keys = listOf("v", "D")
|
||||
val before = """
|
||||
@ -251,6 +263,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion multiline`() {
|
||||
val keys = listOf("vj", "D")
|
||||
val before = """
|
||||
@ -271,6 +284,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple deletion multiline motion up`() {
|
||||
val keys = listOf("vk", "D")
|
||||
val before = """
|
||||
@ -292,6 +306,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test delete visual lines end action`() {
|
||||
typeTextInFile(
|
||||
"v" + "2j" + "D",
|
||||
@ -310,6 +325,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test line simple deletion`() {
|
||||
val keys = listOf("V", "D")
|
||||
val before = """
|
||||
@ -331,6 +347,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test line deletion with indent`() {
|
||||
val keys = listOf("V", "D")
|
||||
val before = """
|
||||
@ -353,6 +370,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test line deletion with indent and nostartofline`() {
|
||||
val keys = listOf("V", "D")
|
||||
val before = """
|
||||
@ -376,6 +394,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test line deletion empty line`() {
|
||||
val keys = listOf("V", "D")
|
||||
val before = """
|
||||
@ -397,6 +416,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test line deletion last line`() {
|
||||
val keys = listOf("V", "D")
|
||||
val before = """
|
||||
@ -420,6 +440,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test line deletion last line without empty line`() {
|
||||
val keys = listOf("V", "D")
|
||||
val before = """
|
||||
@ -441,6 +462,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test line deletion multiline`() {
|
||||
val keys = listOf("Vj", "D")
|
||||
val before = """
|
||||
@ -461,6 +483,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test line deletion multiline motion up`() {
|
||||
val keys = listOf("Vk", "D")
|
||||
val before = """
|
||||
@ -482,6 +505,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test line delete visual lines end action`() {
|
||||
typeTextInFile(
|
||||
"V" + "2j" + "D",
|
||||
@ -500,6 +524,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test block simple deletion`() {
|
||||
val keys = listOf("<C-V>", "D")
|
||||
val before = """
|
||||
@ -522,6 +547,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test block deletion empty line`() {
|
||||
val keys = listOf("<C-V>", "D")
|
||||
val before = """
|
||||
@ -544,6 +570,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test block deletion last line`() {
|
||||
val keys = listOf("<C-V>", "D")
|
||||
val before = """
|
||||
@ -568,6 +595,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test block deletion last line without empty line`() {
|
||||
val keys = listOf("<C-V>", "D")
|
||||
val before = """
|
||||
@ -590,6 +618,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test block deletion multiline`() {
|
||||
val keys = listOf("<C-V>j", "D")
|
||||
val before = """
|
||||
@ -612,6 +641,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test block deletion multiline motion up`() {
|
||||
val keys = listOf("<C-V>k", "D")
|
||||
val before = """
|
||||
@ -634,6 +664,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test delete visual block line end action`() {
|
||||
typeTextInFile(
|
||||
"<C-V>" + "2j" + "2l" + "D",
|
||||
@ -660,6 +691,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.virtualedit, OptionValueType.STRING, OptionConstants.virtualedit_onemore))
|
||||
@Test
|
||||
fun `test change dollar`() {
|
||||
doTest(
|
||||
"c$",
|
||||
|
@ -20,52 +20,56 @@ import org.jetbrains.plugins.ideavim.OptionValueType
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class JoinNotificationTest : VimOptionTestCase(IjOptionConstants.ideajoin) {
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideajoin, OptionValueType.NUMBER, "0"))
|
||||
@Test
|
||||
fun `test notification shown for no ideajoin`() {
|
||||
val before = "I found${c} it\n in a legendary land"
|
||||
configureByText(before)
|
||||
appReadySetup(false)
|
||||
typeText(injector.parser.parseKeys("J"))
|
||||
|
||||
val notification = ActionCenter.getNotifications(myFixture.project, true).last()
|
||||
val notification = ActionCenter.getNotifications(fixture.project, true).last()
|
||||
try {
|
||||
assertEquals(NotificationService.IDEAVIM_NOTIFICATION_TITLE, notification.title)
|
||||
assertTrue(IjOptionConstants.ideajoin in notification.content)
|
||||
assertEquals(3, notification.actions.size)
|
||||
kotlin.test.assertEquals(NotificationService.IDEAVIM_NOTIFICATION_TITLE, notification.title)
|
||||
kotlin.test.assertTrue(IjOptionConstants.ideajoin in notification.content)
|
||||
kotlin.test.assertEquals(3, notification.actions.size)
|
||||
} finally {
|
||||
notification.expire()
|
||||
}
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideajoin, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test notification not shown for ideajoin`() {
|
||||
val before = "I found${c} it\n in a legendary land"
|
||||
configureByText(before)
|
||||
appReadySetup(false)
|
||||
typeText(injector.parser.parseKeys("J"))
|
||||
|
||||
val notifications = ActionCenter.getNotifications(myFixture.project, true)
|
||||
assertTrue(notifications.isEmpty() || notifications.last().isExpired || IjOptionConstants.ideajoin !in notifications.last().content)
|
||||
val notifications = ActionCenter.getNotifications(fixture.project, true)
|
||||
kotlin.test.assertTrue(notifications.isEmpty() || notifications.last().isExpired || IjOptionConstants.ideajoin !in notifications.last().content)
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideajoin, OptionValueType.NUMBER, "0"))
|
||||
@Test
|
||||
fun `test notification not shown if was shown already`() {
|
||||
val before = "I found${c} it\n in a legendary land"
|
||||
configureByText(before)
|
||||
appReadySetup(true)
|
||||
typeText(injector.parser.parseKeys("J"))
|
||||
|
||||
val notifications = EventLog.getLogModel(myFixture.project).notifications
|
||||
assertTrue(notifications.isEmpty() || notifications.last().isExpired || IjOptionConstants.ideajoin !in notifications.last().content)
|
||||
val notifications = EventLog.getLogModel(fixture.project).notifications
|
||||
kotlin.test.assertTrue(notifications.isEmpty() || notifications.last().isExpired || IjOptionConstants.ideajoin !in notifications.last().content)
|
||||
}
|
||||
|
||||
private fun appReadySetup(notifierEnabled: Boolean) {
|
||||
EventLog.markAllAsRead(myFixture.project)
|
||||
EventLog.markAllAsRead(fixture.project)
|
||||
VimPlugin.getVimState().isIdeaJoinNotified = notifierEnabled
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,11 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertAfterCursorActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@Test
|
||||
fun `test insert after cursor with inlay with preceding text places caret between inlay and preceding text`() {
|
||||
configureByText("I found it i${c}n a legendary land")
|
||||
// Inlay is at vp 13. Preceding text is at 12. Caret should be between preceding and inlay = 13
|
||||
@ -25,6 +27,7 @@ class InsertAfterCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@Test
|
||||
fun `test insert after cursor with inlay with following text places caret between inlay and following text`() {
|
||||
configureByText("I found it$c in a legendary land")
|
||||
// Inlay is at offset 11, following text is at vp 12
|
||||
|
@ -11,8 +11,10 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertAfterLineEndActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test insert after line end action`() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("A" + " four" + "<ESC>"),
|
||||
@ -31,6 +33,7 @@ class InsertAfterLineEndActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test multiple carets`() {
|
||||
doTest(
|
||||
"AHello<esc>",
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertBackspaceActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test insert backspace`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I f${c}und it in a legendary land"
|
||||
@ -25,6 +27,7 @@ class InsertBackspaceActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test insert backspace scrolls start of line`() {
|
||||
configureByColumns(200)
|
||||
enterCommand("set sidescrolloff=10")
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertBeforeCursorActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test check caret shape`() {
|
||||
doTest("i", "123", "123", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
assertCaretsVisualAttributes()
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertBeforeFirstNonBlankActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test insert multiple carets`() {
|
||||
doTest(
|
||||
"IHello<esc>",
|
||||
|
@ -12,39 +12,26 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.experimental.theories.DataPoints
|
||||
import org.junit.experimental.theories.Theories
|
||||
import org.junit.experimental.theories.Theory
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@RunWith(Theories::class)
|
||||
class InsertCompletedLiteralActionTest : VimTestCase() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val octalPrefix = listOf("o", "O")
|
||||
@DataPoints("octalPrefix")
|
||||
get
|
||||
|
||||
@JvmStatic
|
||||
val shortHexPrefix = listOf("x", "X")
|
||||
@DataPoints("shortHexPrefix")
|
||||
get
|
||||
|
||||
@JvmStatic
|
||||
val hexPrefix = listOf("u")
|
||||
@DataPoints("hexPrefix")
|
||||
get
|
||||
|
||||
@JvmStatic
|
||||
val longHexPrefix = listOf("U")
|
||||
@DataPoints("longHexPrefix")
|
||||
get
|
||||
|
||||
@JvmStatic
|
||||
val insertDigraph = listOf("<C-v>", "<C-q>")
|
||||
@DataPoints("insertDigraph")
|
||||
get
|
||||
}
|
||||
|
||||
private fun checkInsert(code: String, result: String) {
|
||||
@ -60,7 +47,6 @@ class InsertCompletedLiteralActionTest : VimTestCase() {
|
||||
// FYI space key after code will be sent via VimPlugin.getMacro().postKey(key, editor);, that's why we ignore the last space in tests
|
||||
// fun `octal codes`(@FromDataPoints("octalPrefix") prefix: String) {
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@Theory
|
||||
fun `octal codes`() {
|
||||
for (prefix in octalPrefix) {
|
||||
checkInsert("$prefix ", " ")
|
||||
@ -72,7 +58,6 @@ class InsertCompletedLiteralActionTest : VimTestCase() {
|
||||
|
||||
// FYI space key after code will be sent via VimPlugin.getMacro().postKey(key, editor);, that's why we ignore the last space in tests
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@Theory
|
||||
fun `decimal codes`() {
|
||||
checkInsert("1 ", "${1.toChar()}")
|
||||
checkInsert("01 ", "${1.toChar()}")
|
||||
@ -81,7 +66,6 @@ class InsertCompletedLiteralActionTest : VimTestCase() {
|
||||
|
||||
// FYI space key after code will be sent via VimPlugin.getMacro().postKey(key, editor);, that's why we ignore the last space in tests
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@Theory
|
||||
fun `hex codes`() {
|
||||
for (prefix in shortHexPrefix) {
|
||||
checkInsert("$prefix ", " ")
|
||||
@ -110,7 +94,7 @@ class InsertCompletedLiteralActionTest : VimTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
@Theory
|
||||
@Test
|
||||
fun `unexpected prefix ending`() {
|
||||
checkInsert("o<C-a>", 1.toChar().toString())
|
||||
checkInsert("O<C-a>", 1.toChar().toString())
|
||||
@ -127,26 +111,26 @@ class InsertCompletedLiteralActionTest : VimTestCase() {
|
||||
checkInsert("U<Esc>", 27.toChar().toString())
|
||||
}
|
||||
|
||||
@Theory
|
||||
@Test
|
||||
fun `special keys`() {
|
||||
checkInsert("<Esc>", "${27.toChar()}")
|
||||
// checkInsert("<CR>", "${13.toChar()}") exception is thrown because of the \r symbol
|
||||
}
|
||||
|
||||
// todo
|
||||
// @Theory
|
||||
// fun `keycode 10 is not 10 at all`() {
|
||||
// checkInsert("010", 0.toChar().toString())
|
||||
// checkInsert("o012", 0.toChar().toString())
|
||||
// checkInsert("O012", 0.toChar().toString())
|
||||
// checkInsert("010", 0.toChar().toString())
|
||||
// checkInsert("x0A", 0.toChar().toString())
|
||||
// checkInsert("X0A", 0.toChar().toString())
|
||||
// checkInsert("u000A", 0.toChar().toString())
|
||||
// checkInsert("U0000000A", 0.toChar().toString())
|
||||
// }
|
||||
@Test
|
||||
@Disabled
|
||||
fun `keycode 10 is not 10 at all`() {
|
||||
checkInsert("010", 0.toChar().toString())
|
||||
checkInsert("o012", 0.toChar().toString())
|
||||
checkInsert("O012", 0.toChar().toString())
|
||||
checkInsert("010", 0.toChar().toString())
|
||||
checkInsert("x0A", 0.toChar().toString())
|
||||
checkInsert("X0A", 0.toChar().toString())
|
||||
checkInsert("u000A", 0.toChar().toString())
|
||||
checkInsert("U0000000A", 0.toChar().toString())
|
||||
}
|
||||
|
||||
@Theory
|
||||
@Test
|
||||
fun `regular character`() {
|
||||
checkInsert("a", "a")
|
||||
checkInsert("A", "A")
|
||||
@ -197,7 +181,7 @@ class InsertCompletedLiteralActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@Theory
|
||||
@Test
|
||||
fun `control plus character`() {
|
||||
checkInsert("<C-a>", 1.toChar().toString())
|
||||
checkInsert("<C-b>", 2.toChar().toString())
|
||||
|
@ -12,9 +12,11 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertDeleteActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test insert delete`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I fo${c}nd it in a legendary land"
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertDeleteInsertedTextActionTest : VimTestCase() {
|
||||
// VIM-1655
|
||||
@Test
|
||||
fun `test deleted text is not yanked`() {
|
||||
doTest(
|
||||
listOf("yiw", "ea", "Hello", "<C-U>", "<ESC>p"),
|
||||
@ -34,6 +36,7 @@ class InsertDeleteInsertedTextActionTest : VimTestCase() {
|
||||
|
||||
// VIM-1655
|
||||
@VimBehaviorDiffers(description = "Inserted text is not deleted after <C-U>")
|
||||
@Test
|
||||
fun `test deleted text is not yanked after replace`() {
|
||||
doTest(
|
||||
listOf("yiw", "eR", "Hello", "<C-U>", "<ESC>p"),
|
||||
|
@ -14,9 +14,11 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
// VIM-1655
|
||||
@Test
|
||||
fun `test deleted word is not yanked`() {
|
||||
doTest(
|
||||
listOf("yiw", "3wea", "<C-W>", "<ESC>p"),
|
||||
@ -31,6 +33,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test word removed`() {
|
||||
doTest(
|
||||
listOf("i", "<C-W>"),
|
||||
@ -45,6 +48,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test non alpha chars`() {
|
||||
doTest(
|
||||
listOf("i", "<C-W>", "<C-W>", "<C-W>", "<C-W>"),
|
||||
@ -59,6 +63,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test indents and spaces`() {
|
||||
doTest(
|
||||
listOf("i", "<C-W>", "<C-W>", "<C-W>", "<C-W>"),
|
||||
@ -84,6 +89,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
${c}
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
fun `test delete starting from the line end`() {
|
||||
doTest(
|
||||
listOf("i", "<C-W>"),
|
||||
@ -106,6 +112,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-569 |a| |i_CTRL-W|
|
||||
@Test
|
||||
fun `test delete previous word dot eol`() {
|
||||
doTest(
|
||||
listOf("a", "<C-W>"),
|
||||
@ -117,6 +124,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-569 |a| |i_CTRL-W|
|
||||
@Test
|
||||
fun `test delete previous word last after whitespace`() {
|
||||
doTest(
|
||||
listOf("A", "<C-W>"),
|
||||
@ -128,6 +136,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-513 |A| |i_CTRL-W|
|
||||
@Test
|
||||
fun `test delete previous word eol`() {
|
||||
doTest(
|
||||
listOf("A", "<C-W>"),
|
||||
@ -139,6 +148,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
// VIM-112 |i| |i_CTRL-W|
|
||||
@Test
|
||||
fun `test insert delete previous word`() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("i" + "one two three" + "<C-W>"),
|
||||
@ -147,6 +157,7 @@ class InsertDeletePreviousWordActionTest : VimTestCase() {
|
||||
assertState("hello\n" + "one two \n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert delete previous word action`() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("i" + "<C-W>" + "<ESC>"),
|
||||
|
@ -12,8 +12,10 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertEnterActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test insert enter`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks and lavender and tufted grass,
|
||||
@ -30,6 +32,7 @@ class InsertEnterActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
|
||||
@Test
|
||||
fun `test insert enter with C-M`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks and lavender and tufted grass,
|
||||
@ -46,6 +49,7 @@ class InsertEnterActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test insert enter scrolls view up at scrolloff`() {
|
||||
configureByLines(50, "I found it in a legendary land")
|
||||
enterCommand("set scrolloff=10")
|
||||
|
@ -10,12 +10,15 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertExitModeActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test exit visual mode`() {
|
||||
doTest("i<Esc>", "12${c}3", "1${c}23", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test exit visual mode on line start`() {
|
||||
doTest("i<Esc>", "${c}123", "${c}123", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
@ -12,8 +12,10 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test insert new line above`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks and lavender and tufted grass,
|
||||
@ -29,6 +31,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line above with caret in middle of line`() {
|
||||
val before = """I found it in a legendary land
|
||||
|all rocks and ${c}lavender and tufted grass,
|
||||
@ -44,6 +47,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line above matches indent for plain text`() {
|
||||
val before = """ I found it in a legendary land
|
||||
| all rocks and lavender and tufted grass,
|
||||
@ -59,6 +63,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
doTest("O", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line above matches indent for first line of plain text`() {
|
||||
val before = """ ${c}I found it in a legendary land
|
||||
| all rocks and lavender and tufted grass,
|
||||
@ -75,6 +80,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.PLUGIN) // Java support would be a neovim plugin
|
||||
@Test
|
||||
fun `test insert new line above matches indent for java`() {
|
||||
val before = """public class C {
|
||||
| Integer a;
|
||||
@ -92,6 +98,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line above with multiple carets`() {
|
||||
val before = """ I fou${c}nd it in a legendary land
|
||||
| all rocks and laven${c}der and tufted grass,
|
||||
@ -111,6 +118,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test insert new line above at top of screen does not scroll top of screen`() {
|
||||
configureByLines(50, "I found it in a legendary land")
|
||||
enterCommand("set scrolloff=10")
|
||||
@ -120,6 +128,7 @@ class InsertNewLineAboveActionTest : VimTestCase() {
|
||||
assertVisibleArea(5, 39)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line above first line`() {
|
||||
val before = """${c}I found it in a legendary land
|
||||
|all rocks and lavender and tufted grass,
|
||||
|
@ -12,8 +12,10 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test insert new line below`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks and lavender and tufted grass,
|
||||
@ -29,6 +31,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line below with caret in middle of line`() {
|
||||
val before = """I found it in a legendary land
|
||||
|all rocks and ${c}lavender and tufted grass,
|
||||
@ -44,6 +47,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line below matches indent for plain text`() {
|
||||
val before = """ I found it in a legendary land
|
||||
| ${c}all rocks and lavender and tufted grass,
|
||||
@ -59,6 +63,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
doTest("o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line below matches indent for plain text 1`() {
|
||||
val before = """ I found it in a legendary land
|
||||
| $c all rocks and lavender and tufted grass,
|
||||
@ -75,6 +80,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.PLUGIN) // Java support would be a neovim plugin
|
||||
@Test
|
||||
fun `test insert new line below matches indent for java`() {
|
||||
val before = """public class C {
|
||||
| ${c}Integer a;
|
||||
@ -93,6 +99,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.PLUGIN) // Java support would be a neovim plugin
|
||||
@Test
|
||||
fun `test insert new line below matches indent for java 1`() {
|
||||
val before = """public class C {
|
||||
|$c Integer a;
|
||||
@ -110,6 +117,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line below with multiple carets`() {
|
||||
val before = """ I fou${c}nd it in a legendary land
|
||||
| all rocks and laven${c}der and tufted grass,
|
||||
@ -129,6 +137,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test insert new line below at bottom of screen does not scroll bottom of screen`() {
|
||||
configureByLines(50, "I found it in a legendary land")
|
||||
enterCommand("set scrolloff=10")
|
||||
@ -138,6 +147,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
assertVisibleArea(6, 40)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line below with count`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks and lavender and tufted grass,
|
||||
@ -153,6 +163,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
doTest("5o", before, after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line below with count and escape`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks and lavender and tufted grass,
|
||||
@ -172,6 +183,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
doTest("5o123<esc>", before, after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert new line below with folds`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks [and lavender] and tufted grass,
|
||||
@ -191,6 +203,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.FOLDING, "Neovim doesn't support arbitrary folds")
|
||||
@Test
|
||||
fun `test insert new line below with folds 2`() {
|
||||
val before = """I found it in a legendary land
|
||||
|${c}all rocks [and lavender and tufted grass,
|
||||
@ -209,6 +222,7 @@ class InsertNewLineBelowActionTest : VimTestCase() {
|
||||
performTest("o", after, VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test pycharm notebook folders`() {
|
||||
val before = """[I found it in a legendary land
|
||||
|]${c}all rocks and lavender and tufted grass,
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertSingleCommandActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test enter visual`() {
|
||||
doTest(
|
||||
listOf("i", "<C-O>", "vlll", "<Esc>"),
|
||||
|
@ -11,8 +11,10 @@ package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InsertTabActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test insert tab`() {
|
||||
setupChecks {
|
||||
keyHandler = Checks.KeyHandlerMethod.DIRECT_TO_VIM
|
||||
@ -27,6 +29,7 @@ class InsertTabActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test insert tab scrolls at end of line`() {
|
||||
setupChecks {
|
||||
keyHandler = Checks.KeyHandlerMethod.DIRECT_TO_VIM
|
||||
@ -40,6 +43,7 @@ class InsertTabActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test insert tab scrolls at end of line 2`() {
|
||||
configureByColumns(200)
|
||||
enterCommand("set sidescrolloff=10")
|
||||
|
@ -13,9 +13,11 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class VisualBlockAppendActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test visual block append`() {
|
||||
val before = """
|
||||
${c}int a;
|
||||
@ -32,6 +34,7 @@ class VisualBlockAppendActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test visual block append with dollar motion`() {
|
||||
val before = """
|
||||
${c}int a;
|
||||
@ -47,6 +50,7 @@ class VisualBlockAppendActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test append in non block mode`() {
|
||||
doTest(
|
||||
"vwAHello<esc>",
|
||||
|
@ -16,11 +16,13 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class VisualBlockInsertActionTest : VimTestCase() {
|
||||
|
||||
// VIM-1110 |CTRL-V| |v_b_i| |zc|
|
||||
@TestWithoutNeovim(SkipNeovimReason.FOLDING)
|
||||
@Test
|
||||
fun `test block insert after folds`() {
|
||||
configureByJavaText(
|
||||
"""$c/**
|
||||
@ -31,9 +33,9 @@ bar
|
||||
""",
|
||||
)
|
||||
|
||||
myFixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
CodeFoldingManager.getInstance(myFixture.project).updateFoldRegions(myFixture.editor)
|
||||
FoldingUtil.findFoldRegionStartingAtLine(myFixture.editor, 0)!!.isExpanded = false
|
||||
fixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
CodeFoldingManager.getInstance(fixture.project).updateFoldRegions(fixture.editor)
|
||||
FoldingUtil.findFoldRegionStartingAtLine(fixture.editor, 0)!!.isExpanded = false
|
||||
}
|
||||
|
||||
typeText(injector.parser.parseKeys("j" + "<C-V>" + "j" + "I" + "X" + "<Esc>"))
|
||||
@ -49,6 +51,7 @@ Xbar
|
||||
|
||||
// VIM-1379 |CTRL-V| |j| |v_b_I|
|
||||
@TestWithoutNeovim(SkipNeovimReason.VISUAL_BLOCK_MODE)
|
||||
@Test
|
||||
fun `test insert visual block with empty line in the middle`() {
|
||||
doTest(
|
||||
listOf("ll", "<C-V>", "jjI", "_quux_", "<Esc>"),
|
||||
@ -69,6 +72,7 @@ Xbar
|
||||
|
||||
// VIM-632 |CTRL-V| |v_b_I|
|
||||
@TestWithoutNeovim(SkipNeovimReason.VISUAL_BLOCK_MODE)
|
||||
@Test
|
||||
fun `test change visual block`() {
|
||||
doTest(
|
||||
listOf("<C-V>", "j", "I", "quux ", "<Esc>"),
|
||||
@ -89,6 +93,7 @@ Xbar
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test visual block insert`() {
|
||||
val before = """
|
||||
${c}int a;
|
||||
@ -106,6 +111,7 @@ Xbar
|
||||
|
||||
// VIM-1379 |CTRL-V| |j| |v_b_I|
|
||||
@TestWithoutNeovim(SkipNeovimReason.VISUAL_BLOCK_MODE)
|
||||
@Test
|
||||
fun `test insert visual block with shorter line in the middle`() {
|
||||
doTest(
|
||||
listOf("ll", "<C-V>", "jjI", "_quux_", "<Esc>"),
|
||||
@ -127,6 +133,7 @@ Xbar
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.VISUAL_BLOCK_MODE)
|
||||
@Test
|
||||
fun `test insert in non block mode`() {
|
||||
doTest(
|
||||
listOf("vwIHello<esc>"),
|
||||
@ -150,6 +157,7 @@ Xbar
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.VISUAL_BLOCK_MODE)
|
||||
@Test
|
||||
fun `test block mode with inlays`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -178,6 +186,7 @@ Xbar
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.VISUAL_BLOCK_MODE)
|
||||
@Test
|
||||
fun `test insert with block on one line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.change.shift
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ShiftLeftTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test shift till new line`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -37,6 +39,7 @@ class ShiftLeftTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test shift left positions caret at first non-blank char`() {
|
||||
val file = """
|
||||
|A Discovery
|
||||
@ -60,6 +63,7 @@ class ShiftLeftTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test shift left does not move caret with nostartofline`() {
|
||||
val file = """
|
||||
|A Discovery
|
||||
@ -85,6 +89,7 @@ class ShiftLeftTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test shift left positions caret at end of line with nostartofline`() {
|
||||
val file = """
|
||||
|A Discovery
|
||||
@ -109,6 +114,7 @@ class ShiftLeftTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test shift ctrl-D`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.change.shift
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ShiftRightTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun `test shift till new line`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -38,6 +40,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
|
||||
// VIM-407
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftShiftsOneCharacterSingleLine() {
|
||||
configureByText("<caret>w\n")
|
||||
typeText(">>")
|
||||
@ -46,6 +49,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
|
||||
// VIM-407
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftShiftsOneCharacterMultiLine() {
|
||||
configureByText("Hello\n<caret>w\nWorld")
|
||||
typeText(">>")
|
||||
@ -53,6 +57,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftShiftsMultipleCharactersOneLine() {
|
||||
configureByText("<caret>Hello, world!\n")
|
||||
typeText(">>")
|
||||
@ -60,6 +65,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftShiftsMultipleCharactersMultipleLines() {
|
||||
configureByText("<caret>Hello,\nworld!\n")
|
||||
typeText("j>>")
|
||||
@ -67,6 +73,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftsSingleLineSelection() {
|
||||
configureByText("<caret>Hello,\nworld!\n")
|
||||
typeText("jv$>>")
|
||||
@ -74,6 +81,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftsMultiLineSelection() {
|
||||
configureByText("<caret>Hello,\nworld!\n")
|
||||
typeText("vj$>>")
|
||||
@ -81,6 +89,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftsMultiLineSelectionSkipsNewline() {
|
||||
configureByText("<caret>Hello,\nworld!\n\n")
|
||||
typeText("vG$>>")
|
||||
@ -88,6 +97,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftsMultiLineSelectionSkipsNewlineWhenCursorNotInFirstColumn() {
|
||||
configureByText("<caret>Hello,\n\nworld!\n")
|
||||
typeText("lVG>")
|
||||
@ -95,6 +105,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftsMultiLineSelectionAddsTrailingWhitespaceIfTherePreviouslyWas() {
|
||||
configureByText("<caret>Hello,\n \nworld!\n")
|
||||
typeText("lVG>")
|
||||
@ -103,18 +114,21 @@ class ShiftRightTest : VimTestCase() {
|
||||
|
||||
// VIM-705 repeating a multiline indent would only affect last line
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftsMultiLineSelectionRepeat() {
|
||||
configureByText("<caret>a\nb\n")
|
||||
typeText("Vj>.")
|
||||
assertState(" a\n b\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShiftsDontCrashKeyHandler() {
|
||||
configureByText("\n")
|
||||
typeText("<I<>" + "<I<>")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun testShiftsVisualBlockMode() {
|
||||
configureByText("foo<caret>foo\nfoobar\nfoobaz\n")
|
||||
typeText("<C-V>jjl>")
|
||||
@ -122,6 +136,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun `test shift right positions caret at first non-blank char`() {
|
||||
val file = """
|
||||
|A Discovery
|
||||
@ -145,6 +160,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun `test shift right does not move caret with nostartofline`() {
|
||||
val file = """
|
||||
|A Discovery
|
||||
@ -170,6 +186,7 @@ class ShiftRightTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.TABS)
|
||||
@Test
|
||||
fun `test shift ctrl-t`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
|
@ -21,25 +21,28 @@ import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.jetbrains.plugins.ideavim.rangeOf
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class IdeaPutNotificationsTest : VimOptionTestCase(OptionConstants.clipboard) {
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.clipboard, OptionValueType.STRING, ""))
|
||||
@Test
|
||||
fun `test notification exists if no ideaput`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
configureByText(before)
|
||||
appReadySetup(false)
|
||||
val vimEditor = myFixture.editor.vim
|
||||
VimPlugin.getRegister().storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false)
|
||||
val vimEditor = fixture.editor.vim
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false)
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
|
||||
val notification = ActionCenter.getNotifications(myFixture.project, true).last()
|
||||
val notification = ActionCenter.getNotifications(fixture.project, true).last()
|
||||
try {
|
||||
assertEquals(NotificationService.IDEAVIM_NOTIFICATION_TITLE, notification.title)
|
||||
assertTrue(OptionConstants.clipboard_ideaput in notification.content)
|
||||
assertEquals(2, notification.actions.size)
|
||||
kotlin.test.assertEquals(NotificationService.IDEAVIM_NOTIFICATION_TITLE, notification.title)
|
||||
kotlin.test.assertTrue(OptionConstants.clipboard_ideaput in notification.content)
|
||||
kotlin.test.assertEquals(2, notification.actions.size)
|
||||
} finally {
|
||||
notification.expire()
|
||||
}
|
||||
@ -52,33 +55,37 @@ class IdeaPutNotificationsTest : VimOptionTestCase(OptionConstants.clipboard) {
|
||||
OptionConstants.clipboard_ideaput,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test no notification on ideaput`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
configureByText(before)
|
||||
appReadySetup(false)
|
||||
val vimEditor = myFixture.editor.vim
|
||||
VimPlugin.getRegister().storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false)
|
||||
val vimEditor = fixture.editor.vim
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false)
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
|
||||
val notifications = ActionCenter.getNotifications(myFixture.project, true)
|
||||
assertTrue(notifications.isEmpty() || notifications.last().isExpired || OptionConstants.clipboard_ideaput !in notifications.last().content)
|
||||
val notifications = ActionCenter.getNotifications(fixture.project, true)
|
||||
kotlin.test.assertTrue(notifications.isEmpty() || notifications.last().isExpired || OptionConstants.clipboard_ideaput !in notifications.last().content)
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.clipboard, OptionValueType.STRING, ""))
|
||||
@Test
|
||||
fun `test no notification if already was`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
configureByText(before)
|
||||
appReadySetup(true)
|
||||
val vimEditor = myFixture.editor.vim
|
||||
VimPlugin.getRegister().storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false)
|
||||
val vimEditor = fixture.editor.vim
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false)
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
|
||||
val notifications = EventLog.getLogModel(myFixture.project).notifications
|
||||
assertTrue(notifications.isEmpty() || notifications.last().isExpired || OptionConstants.clipboard_ideaput !in notifications.last().content)
|
||||
val notifications = EventLog.getLogModel(fixture.project).notifications
|
||||
kotlin.test.assertTrue(notifications.isEmpty() || notifications.last().isExpired || OptionConstants.clipboard_ideaput !in notifications.last().content)
|
||||
}
|
||||
|
||||
private fun appReadySetup(notifierEnabled: Boolean) {
|
||||
EventLog.markAllAsRead(myFixture.project)
|
||||
EventLog.markAllAsRead(fixture.project)
|
||||
VimPlugin.getVimState().isIdeaPutNotified = notifierEnabled
|
||||
}
|
||||
}
|
||||
|
@ -23,21 +23,22 @@ import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.jetbrains.plugins.ideavim.rangeOf
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.awt.datatransfer.Transferable
|
||||
|
||||
class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test platform handlers are called`() {
|
||||
val extension = TestExtension()
|
||||
ExtensionTestUtil.maskExtensions(
|
||||
CopyPastePostProcessor.EP_NAME,
|
||||
listOf(extension),
|
||||
myFixture.testRootDisposable,
|
||||
fixture.testRootDisposable,
|
||||
)
|
||||
ExtensionTestUtil.maskExtensions(
|
||||
CopyPastePreProcessor.EP_NAME,
|
||||
listOf(),
|
||||
myFixture.testRootDisposable,
|
||||
fixture.testRootDisposable,
|
||||
)
|
||||
setRegister('4', "XXX ")
|
||||
doTest(
|
||||
@ -47,9 +48,10 @@ class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
VimStateMachine.Mode.COMMAND,
|
||||
VimStateMachine.SubMode.NONE,
|
||||
)
|
||||
assertEquals(1, extension.calledExtractTransferableData)
|
||||
kotlin.test.assertEquals(1, extension.calledExtractTransferableData)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test put from number register`() {
|
||||
setRegister('4', "XXX ")
|
||||
doTest(
|
||||
@ -83,7 +85,8 @@ class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
VimPlugin.getRegister().storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false)
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -120,7 +123,13 @@ class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
val guardRange = before rangeOf "\nGUARD\n"
|
||||
editor.document.createGuardedBlock(guardRange.startOffset, guardRange.endOffset)
|
||||
val vimEditor = editor.vim
|
||||
injector.registerGroup.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "I found it in a legendary land\n", SelectionType.LINE_WISE, false)
|
||||
injector.registerGroup.storeText(
|
||||
vimEditor,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "I found it in a legendary land\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -145,7 +154,8 @@ class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
VimPlugin.getRegister().storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false)
|
||||
typeText(injector.parser.parseKeys("vep"))
|
||||
val after = """
|
||||
A Discovery
|
||||
|
@ -13,11 +13,13 @@ import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.jetbrains.plugins.ideavim.rangeOf
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class PutTextBeforeCursorActionTest : VimTestCase() {
|
||||
/**
|
||||
* @author Oskar Persson
|
||||
* @author Oskar Persson
|
||||
*/
|
||||
@Test
|
||||
fun `test put visual text character to line twice with separate commands large P`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
|
@ -18,6 +18,7 @@ import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.jetbrains.plugins.ideavim.rangeOf
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@ -29,6 +30,7 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test simple insert via idea`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
configureByText(before)
|
||||
@ -41,11 +43,12 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test insert several times`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
configureByText(before)
|
||||
|
||||
val vimEditor = myFixture.editor.vim
|
||||
val vimEditor = fixture.editor.vim
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false)
|
||||
|
||||
@ -54,6 +57,7 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test insert doesn't clear existing elements`() {
|
||||
val randomUUID = UUID.randomUUID()
|
||||
val before = "${c}I found it in a legendary$randomUUID land"
|
||||
@ -62,16 +66,23 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
CopyPasteManager.getInstance().setContents(TextBlockTransferable("Fill", emptyList(), null))
|
||||
CopyPasteManager.getInstance().setContents(TextBlockTransferable("Buffer", emptyList(), null))
|
||||
|
||||
val vimEditor = myFixture.editor.vim
|
||||
val vimEditor = fixture.editor.vim
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "legendary$randomUUID", SelectionType.CHARACTER_WISE, false)
|
||||
.storeText(
|
||||
vimEditor,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary$randomUUID",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
|
||||
val sizeBefore = CopyPasteManager.getInstance().allContents.size
|
||||
typeText("ve", "p")
|
||||
assertEquals(sizeBefore, CopyPasteManager.getInstance().allContents.size)
|
||||
kotlin.test.assertEquals(sizeBefore, CopyPasteManager.getInstance().allContents.size)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test insert block with newline`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -82,7 +93,7 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
|
||||
val vimEditor = myFixture.editor.vim
|
||||
val vimEditor = fixture.editor.vim
|
||||
VimPlugin.getRegister().storeText(
|
||||
vimEditor,
|
||||
vimEditor.primaryCaret(),
|
||||
|
@ -19,7 +19,7 @@ import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.jetbrains.plugins.ideavim.rangeOf
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
@ -43,8 +43,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 1: Copied | Characterwise | --- pasted | Characterwise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual line without copy`() {
|
||||
val before = """
|
||||
${c}I found it in a legendary land
|
||||
@ -58,8 +58,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text without copy`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
configureByText(before)
|
||||
@ -68,8 +68,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -80,8 +80,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text twice`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -92,8 +92,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text full line`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -104,8 +104,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text multicaret`() {
|
||||
val before = "${c}I found ${c}it in a ${c}legendary land"
|
||||
configureByText(before)
|
||||
@ -115,8 +115,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text another direction`() {
|
||||
val before = "I foun${c}d it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -129,8 +129,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 2: Copied | Linewise | --- pasted | Characterwise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -157,8 +157,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise in middle`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -185,8 +185,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise last line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -213,8 +213,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise last line full line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -241,8 +241,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise multicaret`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -272,8 +272,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise multicaret on same line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -301,8 +301,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise multicaret on same line twice`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -334,8 +334,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 3: Copied | Blockwise | --- pasted | Characterwise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -370,8 +370,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise on last line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -408,8 +408,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise on last line twice`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -446,8 +446,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise multicaret`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -486,8 +486,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 4: Copied | Characterwise | --- pasted | Linewise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -512,8 +512,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to line twice`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -549,8 +549,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
${c}Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to last line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -586,8 +586,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
${c}Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to line multicaret`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -622,8 +622,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
${c}Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to line multicaret on same line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -650,8 +650,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 5: Copied | Linewise | --- pasted | Linewise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -676,8 +676,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to line twice`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -713,8 +713,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
${c}A Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to last line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -750,8 +750,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
${c}A Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to line multicaret`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -786,8 +786,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
${c}A Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to line multicaret on same line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -814,8 +814,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 6: Copied | Blockwise | --- pasted | Linewise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise to line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -869,8 +869,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|ere i|
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise on last line to line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -930,8 +930,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|ere i|
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise on last line twice to line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -990,8 +990,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|ere i|
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise multicaret to line`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1034,8 +1034,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 7: Copied | Characterwise | --- pasted | Blockwise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual block without copy`() {
|
||||
val before = """
|
||||
I $c|found| it in a legendary land
|
||||
@ -1050,8 +1050,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to block`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1076,8 +1076,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to block motion up`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1102,8 +1102,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to block twice`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1128,8 +1128,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text character to block with dollar motion`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1167,8 +1167,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
hard by the torrent of a mountain pass.
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to block`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1195,8 +1195,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to block before caret`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1234,8 +1234,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
hard by the torrent of a mountain pass.
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to block twice`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1274,8 +1274,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
${c}A Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to block till end`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1313,8 +1313,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
hard by the torrent of a mountain pass.
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line to block with dollar motion`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1343,8 +1343,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
|
||||
// ----- Case 9: Copied | Blockwise | --- pasted | Blockwise | ---| small p |--------------------
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise to block`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1379,8 +1379,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise to longer block`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1415,8 +1415,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise to shorter block`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1451,8 +1451,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise to shorter block on line end`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1488,8 +1488,8 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise to block with dollar motion`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -1525,6 +1525,7 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text blockwise to block with dollar motion1`() {
|
||||
val before = """
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi gravida commodo orci, egestas placerat purus rhoncus non. Donec efficitur placerat lorem, non ullamcorper nisl. Aliquam vestibulum, purus a pretium sodales, lorem libero placerat tortor, ut gravida est arcu nec purus. Suspendisse luctus euismod mi, at consectetur sapien facilisis sed. Duis eu magna id nisi lacinia vehicula in quis mauris. Donec tincidunt, erat in euismod placerat, tortor eros efficitur ligula, non finibus metus enim in ex. Nam commodo libero quis vestibulum congue. Vivamus sit amet tincidunt orci, in luctus tortor. Ut aliquam porttitor pharetra. Sed vel mi lacinia, auctor eros vel, condimentum eros. Fusce suscipit auctor venenatis. Aliquam elit risus, eleifend quis mollis eu, venenatis quis ex. Nunc varius consectetur eros sit amet efficitur. Donec a elit rutrum, tristique est in, maximus sem. Donec eleifend magna vitae suscipit viverra. Phasellus luctus aliquam tellus viverra consequat.
|
||||
|
@ -18,6 +18,8 @@ import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.Ignore
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
@ -26,6 +28,7 @@ import org.junit.Ignore
|
||||
class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -37,6 +40,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -52,6 +56,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text line linewise`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -63,6 +68,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test replace row`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -98,6 +104,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
${c}A Discovery
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
fun `test put line in block selection`() {
|
||||
val file = """
|
||||
${c}A Discovery
|
||||
@ -122,6 +129,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test Put visual text linewise`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -137,6 +145,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test Put visual text`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -148,6 +157,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test Put visual text full line`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -159,6 +169,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test Put visual text line linewise`() {
|
||||
val before = "${c}I found it in a legendary land"
|
||||
val editor = configureByText(before)
|
||||
@ -170,6 +181,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
|
||||
@Test
|
||||
fun `test Put line in block selection`() {
|
||||
val file = """
|
||||
${c}A Discovery
|
||||
@ -194,6 +206,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
|
||||
// Legacy tests
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual text linewise multicaret`() {
|
||||
val before = """
|
||||
q${c}werty
|
||||
@ -246,6 +259,7 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test put visual block linewise`() {
|
||||
val before = """
|
||||
qw${c}e
|
||||
@ -274,7 +288,9 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
|
||||
@Suppress("unused")
|
||||
@Ignore
|
||||
fun `ignoretest put visual text multicaret`() {
|
||||
@Test
|
||||
@Disabled
|
||||
fun `test put visual text multicaret`() {
|
||||
val before = "${c}qwe asd ${c}zxc rty ${c}fgh vbn"
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
|
@ -14,11 +14,13 @@ import org.jetbrains.plugins.ideavim.OptionValueType
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class YankAndPutTest : VimOptionTestCase(OptionConstants.clipboard) {
|
||||
@VimOptionTestConfiguration(
|
||||
VimTestOption(OptionConstants.clipboard, OptionValueType.STRING, OptionConstants.clipboard_unnamed),
|
||||
)
|
||||
@Test
|
||||
fun `test yank to number register with unnamed`() {
|
||||
val before = """
|
||||
I ${c}found it in a legendary land
|
||||
@ -47,6 +49,7 @@ class YankAndPutTest : VimOptionTestCase(OptionConstants.clipboard) {
|
||||
OptionConstants.clipboard_unnamed + "," + OptionConstants.clipboard_ideaput,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test yank to number register with unnamed and ideaput`() {
|
||||
val before = """
|
||||
I ${c}found it in a legendary land
|
||||
@ -69,6 +72,7 @@ class YankAndPutTest : VimOptionTestCase(OptionConstants.clipboard) {
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.clipboard, OptionValueType.STRING, ""))
|
||||
@Test
|
||||
fun `test yank to number register`() {
|
||||
val before = """
|
||||
I ${c}found it in a legendary land
|
||||
|
@ -11,8 +11,10 @@ package org.jetbrains.plugins.ideavim.action.copy
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class YankLineActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test yank to number register`() {
|
||||
val before = """
|
||||
${c}I found it in a legendary land
|
||||
@ -21,6 +23,6 @@ class YankLineActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
typeText(injector.parser.parseKeys("\"4yy"))
|
||||
val register = VimPlugin.getRegister().getRegister('4')!!
|
||||
assertEquals("I found it in a legendary land\n", register.text)
|
||||
kotlin.test.assertEquals("I found it in a legendary land\n", register.text)
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,11 @@ package org.jetbrains.plugins.ideavim.action.copy
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class YankMotionActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test yank till new line`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -26,9 +27,10 @@ class YankMotionActionTest : VimTestCase() {
|
||||
typeTextInFile("yW", file)
|
||||
val text = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
|
||||
TestCase.assertEquals("and", text)
|
||||
kotlin.test.assertEquals("and", text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank caret doesn't move`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -40,46 +42,50 @@ class YankMotionActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(file)
|
||||
|
||||
val initialOffset = myFixture.editor.caretModel.offset
|
||||
val initialOffset = fixture.editor.caretModel.offset
|
||||
typeText("yy")
|
||||
|
||||
TestCase.assertEquals(initialOffset, myFixture.editor.caretModel.offset)
|
||||
kotlin.test.assertEquals(initialOffset, fixture.editor.caretModel.offset)
|
||||
}
|
||||
|
||||
@Suppress("DANGEROUS_CHARACTERS")
|
||||
@Test
|
||||
fun `test unnamed saved to " register`() {
|
||||
configureByText("I found it in a ${c}legendary land")
|
||||
enterCommand("set clipboard=unnamed")
|
||||
typeText("yiw")
|
||||
|
||||
val starRegister = VimPlugin.getRegister().getRegister('*') ?: kotlin.test.fail("Register * is empty")
|
||||
assertEquals("legendary", starRegister.text)
|
||||
kotlin.test.assertEquals("legendary", starRegister.text)
|
||||
|
||||
val quoteRegister = VimPlugin.getRegister().getRegister('"') ?: kotlin.test.fail("Register \" is empty")
|
||||
assertEquals("legendary", quoteRegister.text)
|
||||
kotlin.test.assertEquals("legendary", quoteRegister.text)
|
||||
}
|
||||
|
||||
@Suppress("DANGEROUS_CHARACTERS")
|
||||
@Test
|
||||
fun `test z saved to " register`() {
|
||||
configureByText("I found it in a ${c}legendary land")
|
||||
typeText("\"zyiw")
|
||||
|
||||
val starRegister = VimPlugin.getRegister().getRegister('z') ?: kotlin.test.fail("Register z is empty")
|
||||
assertEquals("legendary", starRegister.text)
|
||||
kotlin.test.assertEquals("legendary", starRegister.text)
|
||||
|
||||
val quoteRegister = VimPlugin.getRegister().getRegister('"') ?: kotlin.test.fail("Register \" is empty")
|
||||
assertEquals("legendary", quoteRegister.text)
|
||||
kotlin.test.assertEquals("legendary", quoteRegister.text)
|
||||
}
|
||||
|
||||
@Suppress("DANGEROUS_CHARACTERS")
|
||||
@Test
|
||||
fun `test " saved to " register`() {
|
||||
configureByText("I found it in a ${c}legendary land")
|
||||
typeText("\"zyiw")
|
||||
|
||||
val quoteRegister = VimPlugin.getRegister().getRegister('"') ?: kotlin.test.fail("Register \" is empty")
|
||||
assertEquals("legendary", quoteRegister.text)
|
||||
kotlin.test.assertEquals("legendary", quoteRegister.text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank up`() {
|
||||
val file = """
|
||||
A ${c}Discovery
|
||||
@ -91,9 +97,10 @@ class YankMotionActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
typeTextInFile("yk", file)
|
||||
|
||||
assertTrue(injector.messages.isError())
|
||||
kotlin.test.assertTrue(injector.messages.isError())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank dollar at last empty line`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -107,9 +114,10 @@ class YankMotionActionTest : VimTestCase() {
|
||||
typeTextInFile("y$", file)
|
||||
val text = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
|
||||
TestCase.assertEquals("", text)
|
||||
kotlin.test.assertEquals("", text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank to star with mapping`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -123,9 +131,10 @@ class YankMotionActionTest : VimTestCase() {
|
||||
typeTextInFile("\"*yiw", file)
|
||||
val text = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
|
||||
TestCase.assertEquals("legendary", text)
|
||||
kotlin.test.assertEquals("legendary", text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank to star with yank mapping`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -137,9 +146,10 @@ class YankMotionActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
typeTextInFile(commandToKeys("map * *yiw"), file)
|
||||
typeTextInFile("\"*", file)
|
||||
assertNull(VimPlugin.getRegister().lastRegister?.text)
|
||||
kotlin.test.assertNull(VimPlugin.getRegister().lastRegister?.text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank last line`() {
|
||||
val file = """
|
||||
A Discovery
|
||||
@ -153,6 +163,6 @@ class YankMotionActionTest : VimTestCase() {
|
||||
doTest("yy", file, file)
|
||||
val text = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
|
||||
assertEquals("hard by the torrent of a mountain pass.\n", text)
|
||||
kotlin.test.assertEquals("hard by the torrent of a mountain pass.\n", text)
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,13 @@ import com.maddyhome.idea.vim.newapi.vim
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
import javax.swing.KeyStroke
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class YankVisualActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test simple yank`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("viw" + "y"),
|
||||
@ -38,6 +42,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers("\n")
|
||||
@Test
|
||||
fun `test yank empty line`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("v" + "y"),
|
||||
@ -55,6 +60,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers("land\n")
|
||||
@Test
|
||||
fun `test yank to the end`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("viwl" + "y"),
|
||||
@ -71,6 +77,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank multicaret`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
@ -82,39 +89,42 @@ class YankVisualActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
typeText(injector.parser.parseKeys("viw" + "y"))
|
||||
val editor = myFixture.editor.vim
|
||||
val editor = fixture.editor.vim
|
||||
val lastRegister = injector.registerGroup.lastRegisterChar
|
||||
val registers = editor.carets().map { it.registerStorage.getRegister(lastRegister)?.rawText }
|
||||
assertEquals(listOf("found", "was"), registers)
|
||||
kotlin.test.assertEquals(listOf("found", "was"), registers)
|
||||
}
|
||||
|
||||
// todo multicaret
|
||||
// @TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
// fun testYankVisualRange() {
|
||||
// val before = """
|
||||
// q${c}werty
|
||||
// asdf${c}gh
|
||||
// ${c}zxcvbn
|
||||
//
|
||||
// """.trimIndent()
|
||||
// configureByText(before)
|
||||
// typeText(injector.parser.parseKeys("vey"))
|
||||
//
|
||||
// val lastRegister = VimPlugin.getRegister().lastRegister
|
||||
// TestCase.assertNotNull(lastRegister)
|
||||
// val text = lastRegister!!.text
|
||||
// TestCase.assertNotNull(text)
|
||||
//
|
||||
// typeText(injector.parser.parseKeys("G" + "$" + "p"))
|
||||
// val after = """
|
||||
// qwerty
|
||||
// asdfgh
|
||||
// zxcvbn
|
||||
// wert${c}yg${c}hzxcvb${c}n
|
||||
// """.trimIndent()
|
||||
// assertState(after)
|
||||
// }
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
@Disabled
|
||||
fun testYankVisualRange() {
|
||||
val before = """
|
||||
q${c}werty
|
||||
asdf${c}gh
|
||||
${c}zxcvbn
|
||||
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
typeText(injector.parser.parseKeys("vey"))
|
||||
|
||||
val lastRegister = VimPlugin.getRegister().lastRegister
|
||||
assertNotNull<Any>(lastRegister)
|
||||
val text = lastRegister.text
|
||||
assertNotNull<Any>(text)
|
||||
|
||||
typeText(injector.parser.parseKeys("G" + "$" + "p"))
|
||||
val after = """
|
||||
qwerty
|
||||
asdfgh
|
||||
zxcvbn
|
||||
wert${c}yg${c}hzxcvb${c}n
|
||||
""".trimIndent()
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank line`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("V" + "y"),
|
||||
@ -131,6 +141,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank last line`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("V" + "y"),
|
||||
@ -147,6 +158,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank multicaret line`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
@ -158,16 +170,17 @@ class YankVisualActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
typeText(injector.parser.parseKeys("V" + "y"))
|
||||
val editor = myFixture.editor.vim
|
||||
val editor = fixture.editor.vim
|
||||
val lastRegister = injector.registerGroup.lastRegisterChar
|
||||
val registers = editor.carets().map { it.registerStorage.getRegister(lastRegister)?.rawText }
|
||||
assertEquals(
|
||||
kotlin.test.assertEquals(
|
||||
listOf("all rocks and lavender and tufted grass,\n", "hard by the torrent of a mountain pass.\n"),
|
||||
registers,
|
||||
registers
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testYankVisualLines() {
|
||||
val before = """
|
||||
q${c}we
|
||||
@ -197,6 +210,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
assertState(after)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test block yank`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("<C-V>lj" + "y"),
|
||||
@ -213,6 +227,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test block yank with dollar motion`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("<C-V>3j$" + "y"),
|
||||
@ -234,6 +249,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test block yank with dollar motion backward`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("<C-V>k$" + "y"),
|
||||
@ -253,6 +269,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank to numbered register in visual`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("ve" + "\"2y"),
|
||||
@ -269,6 +286,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test yank to numbered register`() {
|
||||
doTest(
|
||||
injector.parser.parseKeys("\"2yy"),
|
||||
@ -292,7 +310,7 @@ class YankVisualActionTest : VimTestCase() {
|
||||
val lastRegister = VimPlugin.getRegister().lastRegister!!
|
||||
val text = lastRegister.text
|
||||
val type = lastRegister.type
|
||||
assertEquals(expectedText, text)
|
||||
assertEquals(expectedType, type)
|
||||
kotlin.test.assertEquals(expectedText, text)
|
||||
kotlin.test.assertEquals(expectedType, type)
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,14 @@ package org.jetbrains.plugins.ideavim.action.copy
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
*/
|
||||
class YankVisualLinesActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test from visual mode`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
@ -35,9 +36,10 @@ class YankVisualLinesActionTest : VimTestCase() {
|
||||
configureByText(text)
|
||||
typeText(injector.parser.parseKeys("vjY"))
|
||||
val savedText = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
TestCase.assertEquals(yankedTest, savedText)
|
||||
kotlin.test.assertEquals(yankedTest, savedText)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test from visual mode till the end`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
@ -62,9 +64,10 @@ class YankVisualLinesActionTest : VimTestCase() {
|
||||
|
||||
""".trimIndent()
|
||||
val savedText = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
TestCase.assertEquals(yankedTest, savedText)
|
||||
kotlin.test.assertEquals(yankedTest, savedText)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test from line visual mode`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
@ -82,6 +85,6 @@ class YankVisualLinesActionTest : VimTestCase() {
|
||||
configureByText(text)
|
||||
typeText(injector.parser.parseKeys("VjY"))
|
||||
val savedText = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
TestCase.assertEquals(yankedTest, savedText)
|
||||
kotlin.test.assertEquals(yankedTest, savedText)
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,12 @@ import com.maddyhome.idea.vim.common.Direction
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
class GnNextTextObjectTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test delete word`() {
|
||||
doTestWithSearch(
|
||||
injector.parser.parseKeys("dgn"),
|
||||
@ -34,6 +36,7 @@ class GnNextTextObjectTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test delete second word`() {
|
||||
doTestWithSearch(
|
||||
injector.parser.parseKeys("2dgn"),
|
||||
@ -49,6 +52,7 @@ class GnNextTextObjectTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test with repeat`() {
|
||||
doTestWithSearch(
|
||||
injector.parser.parseKeys("cgnNewValue<ESC>..."),
|
||||
@ -69,6 +73,7 @@ class GnNextTextObjectTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test gn uses last used pattern not just search pattern`() {
|
||||
doTest(
|
||||
listOf("/is<CR>", ":s/test/tester/<CR>", "0", "dgn"),
|
||||
@ -81,7 +86,7 @@ class GnNextTextObjectTest : VimTestCase() {
|
||||
|
||||
private fun doTestWithSearch(keys: List<KeyStroke>, before: String, after: String) {
|
||||
configureByText(before)
|
||||
VimPlugin.getSearch().setLastSearchState(myFixture.editor, "test", "", Direction.FORWARDS)
|
||||
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
|
@ -17,10 +17,12 @@ import com.maddyhome.idea.vim.common.Direction
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
class GnPreviousTextObjectTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test delete word`() {
|
||||
doTestWithSearch(
|
||||
injector.parser.parseKeys("dgN"),
|
||||
@ -34,6 +36,7 @@ class GnPreviousTextObjectTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun `test delete second word`() {
|
||||
doTestWithSearch(
|
||||
injector.parser.parseKeys("2dgN"),
|
||||
@ -48,6 +51,7 @@ class GnPreviousTextObjectTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test gn uses last used pattern not just search pattern`() {
|
||||
doTest(
|
||||
listOf("/is<CR>", ":s/test/tester/<CR>", "$", "dgN"),
|
||||
@ -60,7 +64,7 @@ class GnPreviousTextObjectTest : VimTestCase() {
|
||||
|
||||
private fun doTestWithSearch(keys: List<KeyStroke>, before: String, after: String) {
|
||||
configureByText(before)
|
||||
VimPlugin.getSearch().setLastSearchState(myFixture.editor, "test", "", Direction.FORWARDS)
|
||||
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
|
@ -16,10 +16,12 @@ import com.maddyhome.idea.vim.common.Direction
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
class VisualSelectNextSearchTest : VimTestCase() {
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearch() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "b" + "gn"), "h<caret>ello world\nhello world hello world")
|
||||
assertOffset(16)
|
||||
@ -28,16 +30,18 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchMulticaret() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("*" + "b" + "gn"),
|
||||
"h<caret>ello world\nh<caret>ello world hello world",
|
||||
)
|
||||
assertEquals(1, myFixture.editor.caretModel.caretCount)
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertMode(VimStateMachine.Mode.VISUAL)
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchFordAndBack() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("*" + "2b" + "gn" + "gN"),
|
||||
@ -49,9 +53,10 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.UNCLEAR)
|
||||
@Test
|
||||
fun testWithoutSpaces() {
|
||||
configureByText("test<caret>test")
|
||||
VimPlugin.getSearch().setLastSearchState(myFixture.editor, "test", "", Direction.FORWARDS)
|
||||
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
|
||||
typeText(injector.parser.parseKeys("gn"))
|
||||
assertOffset(7)
|
||||
assertSelection("test")
|
||||
@ -59,6 +64,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchCurrentlyInOne() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "gn"), "h<caret>ello world\nhello world hello world")
|
||||
assertOffset(16)
|
||||
@ -67,6 +73,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchTwice() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "2gn"), "h<caret>ello world\nhello world hello, hello")
|
||||
assertOffset(28)
|
||||
@ -74,6 +81,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchTwiceInVisual() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("*" + "gn" + "2gn"),
|
||||
@ -84,6 +92,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testTwoSearchesStayInVisualMode() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "gn" + "gn"), "h<caret>ello world\nhello world hello, hello")
|
||||
assertOffset(28)
|
||||
@ -92,6 +101,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testCanExitVisualMode() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("*" + "gn" + "gn" + "<Esc>"),
|
||||
@ -102,6 +112,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
assertMode(VimStateMachine.Mode.COMMAND)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNullSelectionDoesNothing() {
|
||||
typeTextInFile(injector.parser.parseKeys("/bye<CR>" + "gn"), "h<caret>ello world\nhello world hello world")
|
||||
assertOffset(1)
|
||||
@ -109,6 +120,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testIfInLastPositionOfSearchAndInNormalModeThenSelectCurrent() {
|
||||
typeTextInFile(injector.parser.parseKeys("*0e" + "gn"), "h<caret>ello hello")
|
||||
assertOffset(4)
|
||||
@ -117,6 +129,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testIfInMiddlePositionOfSearchAndInVisualModeThenSelectCurrent() {
|
||||
typeTextInFile(injector.parser.parseKeys("*0llv" + "gn"), "h<caret>ello hello")
|
||||
assertOffset(4)
|
||||
@ -125,6 +138,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testIfInLastPositionOfSearchAndInVisualModeThenSelectNext() {
|
||||
typeTextInFile(injector.parser.parseKeys("*0ev" + "gn"), "h<caret>ello hello")
|
||||
assertOffset(10)
|
||||
@ -133,6 +147,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testMixWithN() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("*" + "gn" + "n" + "gn"),
|
||||
@ -144,6 +159,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testMixWithPreviousSearch() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("*" + "gn" + "gn" + "gN" + "gn"),
|
||||
@ -155,6 +171,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchWithTabs() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "gn"), "\tf<caret>oo")
|
||||
assertSelection("foo")
|
||||
|
@ -16,10 +16,12 @@ import com.maddyhome.idea.vim.common.Direction
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearch() {
|
||||
typeTextInFile(injector.parser.parseKeys("*w" + "gN"), "h<caret>ello world\nhello world hello world")
|
||||
assertOffset(12)
|
||||
@ -28,16 +30,18 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchMulticaret() {
|
||||
typeTextInFile(
|
||||
injector.parser.parseKeys("*" + "b" + "gN"),
|
||||
"h<caret>ello world\nh<caret>ello world hello world",
|
||||
)
|
||||
assertEquals(1, myFixture.editor.caretModel.caretCount)
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertMode(VimStateMachine.Mode.VISUAL)
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchWhenOnMatch() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "gN"), "h<caret>ello world\nhello world hello world")
|
||||
assertOffset(12)
|
||||
@ -46,9 +50,10 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.DIFFERENT)
|
||||
@Test
|
||||
fun testWithoutSpaces() {
|
||||
configureByText("tes<caret>ttest")
|
||||
VimPlugin.getSearch().setLastSearchState(myFixture.editor, "test", "", Direction.FORWARDS)
|
||||
VimPlugin.getSearch().setLastSearchState(fixture.editor, "test", "", Direction.FORWARDS)
|
||||
typeText(injector.parser.parseKeys("gN"))
|
||||
assertOffset(0)
|
||||
assertSelection("test")
|
||||
@ -56,6 +61,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testSearchTwice() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "2gN"), "hello world\nh<caret>ello world hello")
|
||||
assertOffset(12)
|
||||
@ -63,6 +69,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testTwoSearchesStayInVisualMode() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN"), "hello world\nh<caret>ello world hello")
|
||||
assertOffset(12)
|
||||
@ -71,6 +78,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testCanExitVisualMode() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN" + "<Esc>"), "hello world\nh<caret>ello world hello")
|
||||
assertOffset(12)
|
||||
@ -79,6 +87,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestFor(classes = [SearchWholeWordForwardAction::class])
|
||||
@Test
|
||||
fun testIfInMiddlePositionOfSearchAndInVisualModeThenSelectCurrent() {
|
||||
typeTextInFile(injector.parser.parseKeys("*llv" + "gN"), "hello hello")
|
||||
assertOffset(6)
|
||||
@ -86,6 +95,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
|
||||
assertMode(VimStateMachine.Mode.VISUAL)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWithTabs() {
|
||||
typeTextInFile(injector.parser.parseKeys("*" + "gN" + "gN"), "hello 1\n\thello 2\n\the<caret>llo 3\n\thello 4")
|
||||
assertOffset(18)
|
||||
|
@ -20,6 +20,7 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@ -27,6 +28,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
// related to following (KTIJ-3768). The inline rename options inlay is a better example
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and block caret`() {
|
||||
val before = "I fou${c}nd it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -51,6 +53,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and block caret 2`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
@ -73,6 +76,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and bar caret`() {
|
||||
val before = "I fou${c}nd it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -101,6 +105,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and bar caret 2`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
@ -128,6 +133,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
// Kotlin parameter hints are a good example of inlays related to following text
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to following text with block caret`() {
|
||||
val before = "I fou${c}nd it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -152,6 +158,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to following text with block caret 2`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
@ -174,6 +181,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to following text with bar caret`() {
|
||||
val before = "I fou${c}nd it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -201,6 +209,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to following text with bar caret 2`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
@ -227,6 +236,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test visual default options`() {
|
||||
doTest(
|
||||
listOf("v", "<Left>"),
|
||||
@ -259,6 +269,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopsel,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopsel`() {
|
||||
doTest(
|
||||
listOf("v", "<Left>"),
|
||||
@ -291,6 +302,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopselect,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopselect`() {
|
||||
doTest(
|
||||
listOf("v", "<Left>"),
|
||||
@ -323,6 +335,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopvisual,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopvisual`() {
|
||||
doTest(
|
||||
listOf("v", "<Left>"),
|
||||
@ -355,6 +368,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopvisual,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopvisual multicaret`() {
|
||||
doTest(
|
||||
listOf("v", "<Left>"),
|
||||
@ -381,6 +395,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("<Left>"),
|
||||
@ -397,6 +412,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap at file start`() {
|
||||
doTest(
|
||||
listOf("<Left>"),
|
||||
@ -413,6 +429,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap to previous line`() {
|
||||
doTest(
|
||||
listOf("<Left>"),
|
||||
@ -431,6 +448,7 @@ class MotionArrowLeftActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("<Left>"),
|
||||
|
@ -20,11 +20,13 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and block caret`() {
|
||||
val before = "I f${c}ound it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -49,6 +51,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and block caret 2`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I fou${c}nd it in a legendary land"
|
||||
@ -71,6 +74,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and bar caret`() {
|
||||
val before = "I f${c}ound it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -99,6 +103,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to preceding text and bar caret 2`() {
|
||||
val before = "I fo${c}und it in a legendary land"
|
||||
val after = "I fou${c}nd it in a legendary land"
|
||||
@ -122,7 +127,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
assertVisualPosition(0, 4)
|
||||
|
||||
typeText(injector.parser.parseKeys("<Right>"))
|
||||
myFixture.checkResult(after)
|
||||
fixture.checkResult(after)
|
||||
|
||||
assertOffset(5)
|
||||
assertVisualPosition(0, 6)
|
||||
@ -135,6 +140,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
// Kotlin parameter hints are a good example of inlays related to following text
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to following text and block caret`() {
|
||||
val before = "I f${c}ound it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -158,6 +164,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.INLAYS)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test with inlay related to following text and bar caret`() {
|
||||
val before = "I f${c}ound it in a legendary land"
|
||||
val after = "I fo${c}und it in a legendary land"
|
||||
@ -185,6 +192,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test visual default options`() {
|
||||
doTest(
|
||||
listOf("v", "<Right>"),
|
||||
@ -217,6 +225,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopsel,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopsel`() {
|
||||
doTest(
|
||||
listOf("v", "<Right>"),
|
||||
@ -249,6 +258,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopselect,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopselect`() {
|
||||
doTest(
|
||||
listOf("v", "<Right>"),
|
||||
@ -281,6 +291,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopvisual,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopvisual`() {
|
||||
doTest(
|
||||
listOf("v", "<Right>"),
|
||||
@ -313,6 +324,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopvisual,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test visual stopvisual multicaret`() {
|
||||
doTest(
|
||||
listOf("v", "<Right>"),
|
||||
@ -339,6 +351,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("<Right>"),
|
||||
@ -355,6 +368,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap at file end`() {
|
||||
doTest(
|
||||
listOf("<Right>"),
|
||||
@ -371,6 +385,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap to next line`() {
|
||||
doTest(
|
||||
listOf("<Right>"),
|
||||
@ -389,6 +404,7 @@ class MotionArrowRightActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("<Right>"),
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionBackspaceActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("<BS>"),
|
||||
@ -29,6 +31,7 @@ class MotionBackspaceActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap at file start`() {
|
||||
doTest(
|
||||
listOf("<BS>"),
|
||||
@ -44,6 +47,7 @@ class MotionBackspaceActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap to previous line`() {
|
||||
doTest(
|
||||
listOf("<BS>"),
|
||||
@ -61,6 +65,7 @@ class MotionBackspaceActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("<BS>"),
|
||||
|
@ -19,10 +19,12 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionEndActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test motion end`() {
|
||||
val keys = listOf("<End>")
|
||||
val before = """
|
||||
@ -46,6 +48,7 @@ class MotionEndActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""))
|
||||
@Test
|
||||
fun `test continue visual`() {
|
||||
val keys = listOf("v", "<End>")
|
||||
val before = """
|
||||
@ -69,6 +72,7 @@ class MotionEndActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""))
|
||||
@Test
|
||||
fun `test continue select`() {
|
||||
val keys = listOf("gh", "<End>")
|
||||
val before = """
|
||||
@ -98,6 +102,7 @@ class MotionEndActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopvisual,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test exit visual`() {
|
||||
val keys = listOf("v", "<End>")
|
||||
val before = """
|
||||
@ -127,6 +132,7 @@ class MotionEndActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopselect,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test exit select`() {
|
||||
val keys = listOf("gh", "<End>")
|
||||
val before = """
|
||||
@ -150,6 +156,7 @@ class MotionEndActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test delete to the end`() {
|
||||
val keys = listOf("d", "<End>")
|
||||
val before = """
|
||||
|
@ -19,10 +19,12 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionHomeActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test motion home`() {
|
||||
val keys = "<Home>"
|
||||
val before = """
|
||||
@ -45,13 +47,15 @@ class MotionHomeActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test default stop select`() {
|
||||
val keymodel = optionsNoEditor().getStringListValues(OptionConstants.keymodel)
|
||||
assertTrue(OptionConstants.keymodel_stopselect in keymodel)
|
||||
kotlin.test.assertTrue(OptionConstants.keymodel_stopselect in keymodel)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""))
|
||||
@Test
|
||||
fun `test continue visual`() {
|
||||
val keys = listOf("v", "<Home>")
|
||||
val before = """
|
||||
@ -75,6 +79,7 @@ class MotionHomeActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""))
|
||||
@Test
|
||||
fun `test continue select`() {
|
||||
val keys = listOf("gh", "<Home>")
|
||||
val before = """
|
||||
@ -104,6 +109,7 @@ class MotionHomeActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopvisual,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test exit visual`() {
|
||||
val keys = listOf("v", "<Home>")
|
||||
val before = """
|
||||
@ -133,6 +139,7 @@ class MotionHomeActionTest : VimOptionTestCase(OptionConstants.keymodel) {
|
||||
OptionConstants.keymodel_stopselect,
|
||||
),
|
||||
)
|
||||
@Test
|
||||
fun `test exit select`() {
|
||||
val keys = listOf("gh", "<Home>")
|
||||
val before = """
|
||||
|
@ -15,8 +15,10 @@ import com.maddyhome.idea.vim.helper.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionLastColumnActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test dollar motion`() {
|
||||
val keys = "$"
|
||||
val before = """
|
||||
@ -38,6 +40,7 @@ class MotionLastColumnActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dollar motion with motion to longer line`() {
|
||||
val keys = "\$j"
|
||||
val before = """
|
||||
@ -59,6 +62,7 @@ class MotionLastColumnActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dollar motion in visual block mode`() {
|
||||
val keys = "<C-V>jj\$"
|
||||
val before = """
|
||||
@ -80,6 +84,7 @@ class MotionLastColumnActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dollar motion resets intended location after motion`() {
|
||||
doTest(
|
||||
"\$hlj",
|
||||
@ -112,6 +117,7 @@ class MotionLastColumnActionTest : VimTestCase() {
|
||||
hard by the torrent of a mountain pass.
|
||||
""",
|
||||
)
|
||||
@Test
|
||||
fun `test dollar motion in visual block mode with left motion`() {
|
||||
val keys = "<C-V>jj\$h"
|
||||
val before = """
|
||||
@ -133,6 +139,7 @@ class MotionLastColumnActionTest : VimTestCase() {
|
||||
doTest(keys, before, after, VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test dollar motion from insert mode`() {
|
||||
val keys = "i<C-O>$"
|
||||
val before = """
|
||||
@ -155,6 +162,7 @@ class MotionLastColumnActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
|
||||
@Test
|
||||
fun `test dollar motion from insert mode with deletion`() {
|
||||
val keys = "i<C-O>d$"
|
||||
val before = """
|
||||
|
@ -12,9 +12,11 @@ import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionLeftActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("h"),
|
||||
@ -31,6 +33,7 @@ class MotionLeftActionTest : VimTestCase() {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap at file start`() {
|
||||
doTest(
|
||||
listOf("h"),
|
||||
@ -47,6 +50,7 @@ class MotionLeftActionTest : VimTestCase() {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap to previous line`() {
|
||||
doTest(
|
||||
listOf("h"),
|
||||
@ -65,6 +69,7 @@ class MotionLeftActionTest : VimTestCase() {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("h"),
|
||||
@ -87,6 +92,7 @@ class MotionLeftActionTest : VimTestCase() {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test d command with whichwrap`() {
|
||||
doTest(
|
||||
listOf("dh"),
|
||||
|
@ -12,9 +12,11 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionLeftInsertTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("i", "<Left>"),
|
||||
@ -31,6 +33,7 @@ class MotionLeftInsertTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap at file start`() {
|
||||
doTest(
|
||||
listOf("i", "<Left>"),
|
||||
@ -47,6 +50,7 @@ class MotionLeftInsertTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap to previous line`() {
|
||||
doTest(
|
||||
listOf("i", "<Left>"),
|
||||
@ -65,6 +69,7 @@ class MotionLeftInsertTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("i", "<Left>"),
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionLeftMatchCharActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test move and repeat`() {
|
||||
doTest(
|
||||
"Fx;",
|
||||
@ -22,6 +24,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat twice`() {
|
||||
doTest(
|
||||
"Fx;;",
|
||||
@ -32,6 +35,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat two`() {
|
||||
doTest(
|
||||
"Fx2;",
|
||||
@ -42,6 +46,7 @@ class MotionLeftMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat three`() {
|
||||
doTest(
|
||||
"Fx3;",
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionLeftTillMatchCharActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test move and repeat`() {
|
||||
doTest(
|
||||
"Tx;",
|
||||
@ -22,6 +24,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat twice`() {
|
||||
doTest(
|
||||
"Tx;;",
|
||||
@ -32,6 +35,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat two`() {
|
||||
doTest(
|
||||
"Tx2;",
|
||||
@ -42,6 +46,7 @@ class MotionLeftTillMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat three`() {
|
||||
doTest(
|
||||
"Tx3;",
|
||||
|
@ -19,9 +19,11 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple motion`() {
|
||||
doTest(
|
||||
"l",
|
||||
@ -47,6 +49,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple motion with repeat`() {
|
||||
doTest(
|
||||
"3l",
|
||||
@ -72,6 +75,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple motion to the end`() {
|
||||
doTest(
|
||||
"3l",
|
||||
@ -98,6 +102,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.virtualedit, OptionValueType.STRING, OptionConstants.virtualedit_onemore))
|
||||
@Test
|
||||
fun `test virtual edit motion to the end`() {
|
||||
doTest(
|
||||
"3l",
|
||||
@ -118,6 +123,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionTestConfiguration(VimTestOption(OptionConstants.virtualedit, OptionValueType.STRING, OptionConstants.virtualedit_onemore))
|
||||
@Test
|
||||
fun `test virtual edit motion after dollar`() {
|
||||
doTest(
|
||||
"\$l",
|
||||
@ -138,6 +144,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.NON_ASCII)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple motion non-ascii`() {
|
||||
doTest(
|
||||
"l",
|
||||
@ -164,6 +171,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.NON_ASCII)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple motion emoji`() {
|
||||
doTest(
|
||||
"l",
|
||||
@ -190,6 +198,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.NON_ASCII)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple motion czech`() {
|
||||
doTest(
|
||||
"l",
|
||||
@ -215,6 +224,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple motion tab`() {
|
||||
doTest(
|
||||
"l",
|
||||
@ -240,6 +250,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test char visual mode`() {
|
||||
doTest(
|
||||
listOf("v", "ll"),
|
||||
@ -265,6 +276,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test block visual mode`() {
|
||||
doTest(
|
||||
listOf("<C-V>", "ll"),
|
||||
@ -291,6 +303,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("l"),
|
||||
@ -307,6 +320,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap at file end`() {
|
||||
doTest(
|
||||
listOf("l"),
|
||||
@ -323,6 +337,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test whichwrap to next line`() {
|
||||
doTest(
|
||||
listOf("l"),
|
||||
@ -341,6 +356,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("l"),
|
||||
@ -363,6 +379,7 @@ class MotionRightActionTest : VimOptionTestCase(OptionConstants.virtualedit) {
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test d command with whichwrap`() {
|
||||
doTest(
|
||||
listOf("dl"),
|
||||
|
@ -12,9 +12,11 @@ import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionRightInsertTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("i", "<Right>"),
|
||||
@ -31,6 +33,7 @@ class MotionRightInsertTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap to file end`() {
|
||||
doTest(
|
||||
listOf("i", "<Right>"),
|
||||
@ -47,6 +50,7 @@ class MotionRightInsertTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap at file end`() {
|
||||
doTest(
|
||||
listOf("i", "<Right>"),
|
||||
@ -63,6 +67,7 @@ class MotionRightInsertTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap to next line`() {
|
||||
doTest(
|
||||
listOf("i", "<Right>"),
|
||||
@ -81,6 +86,7 @@ class MotionRightInsertTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("i", "<Right>"),
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionRightMatchCharActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test move and repeat`() {
|
||||
doTest(
|
||||
"fx;",
|
||||
@ -22,6 +24,7 @@ class MotionRightMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat twice`() {
|
||||
doTest(
|
||||
"fx;;",
|
||||
@ -32,6 +35,7 @@ class MotionRightMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat two`() {
|
||||
doTest(
|
||||
"fx2;",
|
||||
@ -42,6 +46,7 @@ class MotionRightMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat three`() {
|
||||
doTest(
|
||||
"fx3;",
|
||||
|
@ -10,8 +10,10 @@ package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
|
||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionRightTillMatchCharActionTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test move and repeat`() {
|
||||
doTest(
|
||||
"tx;",
|
||||
@ -22,6 +24,7 @@ class MotionRightTillMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat twice`() {
|
||||
doTest(
|
||||
"tx;;",
|
||||
@ -32,6 +35,7 @@ class MotionRightTillMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat two`() {
|
||||
doTest(
|
||||
"tx2;",
|
||||
@ -42,6 +46,7 @@ class MotionRightTillMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat three`() {
|
||||
doTest(
|
||||
"tx3;",
|
||||
@ -52,6 +57,7 @@ class MotionRightTillMatchCharActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test move and repeat backwards`() {
|
||||
doTest(
|
||||
"tx,",
|
||||
|
@ -20,10 +20,12 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionShiftEndActionTest : VimOptionTestCase(OptionConstants.keymodel, OptionConstants.selectmode) {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple end`() {
|
||||
val keys = listOf("<S-End>")
|
||||
val before = """
|
||||
@ -50,6 +52,7 @@ class MotionShiftEndActionTest : VimOptionTestCase(OptionConstants.keymodel, Opt
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test start visual`() {
|
||||
val keys = listOf("<S-End>")
|
||||
val before = """
|
||||
@ -76,6 +79,7 @@ class MotionShiftEndActionTest : VimOptionTestCase(OptionConstants.keymodel, Opt
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, OptionConstants.selectmode_key),
|
||||
)
|
||||
@Test
|
||||
fun `test start select`() {
|
||||
val keys = listOf("<S-End>")
|
||||
val before = """
|
||||
@ -102,6 +106,7 @@ class MotionShiftEndActionTest : VimOptionTestCase(OptionConstants.keymodel, Opt
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test continue visual`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -132,6 +137,7 @@ class MotionShiftEndActionTest : VimOptionTestCase(OptionConstants.keymodel, Opt
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test continue select`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
|
@ -20,10 +20,12 @@ import org.jetbrains.plugins.ideavim.VimOptionDefaultAll
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionShiftHomeActionTest : VimOptionTestCase(OptionConstants.keymodel, OptionConstants.selectmode) {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test simple home`() {
|
||||
val keys = listOf("<S-Home>")
|
||||
val before = """
|
||||
@ -46,9 +48,10 @@ class MotionShiftHomeActionTest : VimOptionTestCase(OptionConstants.keymodel, Op
|
||||
}
|
||||
|
||||
@VimOptionDefaultAll
|
||||
@Test
|
||||
fun `test default continueselect`() {
|
||||
val keymodel = optionsNoEditor().getStringListValues(OptionConstants.keymodel)
|
||||
assertTrue(OptionConstants.keymodel_continueselect in keymodel)
|
||||
kotlin.test.assertTrue(OptionConstants.keymodel_continueselect in keymodel)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@ -56,6 +59,7 @@ class MotionShiftHomeActionTest : VimOptionTestCase(OptionConstants.keymodel, Op
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test start visual`() {
|
||||
val keys = listOf("<S-Home>")
|
||||
val before = """
|
||||
@ -82,6 +86,7 @@ class MotionShiftHomeActionTest : VimOptionTestCase(OptionConstants.keymodel, Op
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, OptionConstants.selectmode_key),
|
||||
)
|
||||
@Test
|
||||
fun `test start select`() {
|
||||
val keys = listOf("<S-Home>")
|
||||
val before = """
|
||||
@ -108,6 +113,7 @@ class MotionShiftHomeActionTest : VimOptionTestCase(OptionConstants.keymodel, Op
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test continue visual`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
@ -138,6 +144,7 @@ class MotionShiftHomeActionTest : VimOptionTestCase(OptionConstants.keymodel, Op
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test continue select`() {
|
||||
val before = """
|
||||
A Discovery
|
||||
|
@ -18,6 +18,7 @@ import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymodel, OptionConstants.selectmode) {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@ -25,6 +26,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test visual left`() {
|
||||
doTest(
|
||||
listOf("<S-Left>"),
|
||||
@ -54,6 +56,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test visual left twice`() {
|
||||
doTest(
|
||||
listOf("<S-Left><S-Left>"),
|
||||
@ -83,6 +86,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, OptionConstants.selectmode_key),
|
||||
)
|
||||
@Test
|
||||
fun `test select left`() {
|
||||
doTest(
|
||||
listOf("<S-Left>"),
|
||||
@ -112,6 +116,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, OptionConstants.selectmode_key),
|
||||
)
|
||||
@Test
|
||||
fun `test select left twice`() {
|
||||
doTest(
|
||||
listOf("<S-Left><S-Left>"),
|
||||
@ -141,6 +146,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test simple motion char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Left>"),
|
||||
@ -170,6 +176,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test double motion char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Left>".repeat(2)),
|
||||
@ -199,6 +206,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test at line start char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Left>".repeat(2)),
|
||||
@ -228,6 +236,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test at file start char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Left>".repeat(2)),
|
||||
@ -257,6 +266,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test char mode multicaret`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Left>".repeat(2)),
|
||||
@ -286,6 +296,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test simple motion line mode`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Left>"),
|
||||
@ -315,6 +326,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test to line start line mode`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Left>".repeat(5)),
|
||||
@ -344,6 +356,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test to file start line mode`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Left>".repeat(5)),
|
||||
@ -373,6 +386,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test line mode multicaret`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Left>".repeat(5)),
|
||||
@ -402,6 +416,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test simple motion block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Left>"),
|
||||
@ -431,6 +446,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test twice motion block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Left>".repeat(2)),
|
||||
@ -460,6 +476,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test at line start block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Left>".repeat(2)),
|
||||
@ -489,6 +506,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test at file start block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Left>".repeat(2)),
|
||||
@ -518,6 +536,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test multiline with empty line block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Down>", "<S-Left>".repeat(2)),
|
||||
@ -548,6 +567,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test multiline block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Down>".repeat(2), "<S-Left>".repeat(3)),
|
||||
@ -578,6 +598,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continuevisual),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test continuevisual`() {
|
||||
doTest(
|
||||
listOf("v", "<S-Left>".repeat(3)),
|
||||
@ -607,6 +628,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test no continueselect`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Left>".repeat(3)),
|
||||
@ -636,6 +658,7 @@ class MotionShiftLeftActionHandlerTest : VimOptionTestCase(OptionConstants.keymo
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test no continuevisual`() {
|
||||
doTest(
|
||||
listOf("v", "<S-Left>".repeat(3)),
|
||||
|
@ -18,6 +18,7 @@ import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keymodel, OptionConstants.selectmode) {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@ -25,6 +26,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test visual right`() {
|
||||
doTest(
|
||||
listOf("<S-Right>"),
|
||||
@ -54,6 +56,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test visual right twice`() {
|
||||
doTest(
|
||||
listOf("<S-Right><S-Right>"),
|
||||
@ -83,6 +86,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, OptionConstants.selectmode_key),
|
||||
)
|
||||
@Test
|
||||
fun `test select right`() {
|
||||
doTest(
|
||||
listOf("<S-Right>"),
|
||||
@ -112,6 +116,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_startsel),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, OptionConstants.selectmode_key),
|
||||
)
|
||||
@Test
|
||||
fun `test select right twice`() {
|
||||
doTest(
|
||||
listOf("<S-Right><S-Right>"),
|
||||
@ -141,6 +146,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test simple motion char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Right>"),
|
||||
@ -170,6 +176,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test at the lineend char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Right>"),
|
||||
@ -199,6 +206,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test out of line char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Right>".repeat(2)),
|
||||
@ -228,6 +236,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test file end char mode`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Right>".repeat(2)),
|
||||
@ -257,6 +266,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test file char mode multicaret`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Right>".repeat(2)),
|
||||
@ -286,6 +296,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test simple motion line mode`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Right>"),
|
||||
@ -315,6 +326,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test lineend line mode`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Right>"),
|
||||
@ -344,6 +356,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test out of line line mode`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Right>".repeat(2)),
|
||||
@ -373,6 +386,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test fileend line mode`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Right>"),
|
||||
@ -402,6 +416,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test line mode multicaret`() {
|
||||
doTest(
|
||||
listOf("gH", "<S-Right>"),
|
||||
@ -431,6 +446,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test simple motion block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Right>"),
|
||||
@ -460,6 +476,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test at the lineend block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Right>"),
|
||||
@ -489,6 +506,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test out of line block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Right>".repeat(2)),
|
||||
@ -518,6 +536,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test file end block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Right>".repeat(2)),
|
||||
@ -547,6 +566,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continueselect),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test to longer line block mode`() {
|
||||
doTest(
|
||||
listOf("g<C-H>", "<S-Down>", "<S-Right>".repeat(3)),
|
||||
@ -576,6 +596,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, OptionConstants.keymodel_continuevisual),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test continuevisual`() {
|
||||
doTest(
|
||||
listOf("v", "<S-Right>".repeat(3)),
|
||||
@ -605,6 +626,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test no continueselect`() {
|
||||
doTest(
|
||||
listOf("gh", "<S-Right>".repeat(3)),
|
||||
@ -634,6 +656,7 @@ class MotionShiftRightActionHandlerTest : VimOptionTestCase(OptionConstants.keym
|
||||
VimTestOption(OptionConstants.keymodel, OptionValueType.STRING, ""),
|
||||
VimTestOption(OptionConstants.selectmode, OptionValueType.STRING, ""),
|
||||
)
|
||||
@Test
|
||||
fun `test no continuevisual`() {
|
||||
doTest(
|
||||
listOf("v", "<S-Right>".repeat(3)),
|
||||
|
@ -11,9 +11,11 @@ package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionSpaceActionTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap in the same line`() {
|
||||
doTest(
|
||||
listOf("<Space>"),
|
||||
@ -29,6 +31,7 @@ class MotionSpaceActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap at file end`() {
|
||||
doTest(
|
||||
listOf("<Space>"),
|
||||
@ -44,6 +47,7 @@ class MotionSpaceActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test whichwrap to next line`() {
|
||||
doTest(
|
||||
listOf("<Space>"),
|
||||
@ -61,6 +65,7 @@ class MotionSpaceActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@Test
|
||||
fun `test from empty line to empty line`() {
|
||||
doTest(
|
||||
listOf("<Space>"),
|
||||
|
@ -15,14 +15,15 @@ import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.group.IjOptionConstants
|
||||
import com.maddyhome.idea.vim.group.createLineBookmark
|
||||
import com.maddyhome.idea.vim.group.mnemonic
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.plugins.ideavim.OptionValueType
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MotionMarkActionTest : VimOptionTestCase(IjOptionConstants.ideamarks) {
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideamarks, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test simple add mark`() {
|
||||
val keys = injector.parser.parseKeys("mA")
|
||||
val text = """
|
||||
@ -39,6 +40,7 @@ class MotionMarkActionTest : VimOptionTestCase(IjOptionConstants.ideamarks) {
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideamarks, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test simple add multiple marks`() {
|
||||
val keys = injector.parser.parseKeys("mAj" + "mBj" + "mC")
|
||||
val text = """
|
||||
@ -55,6 +57,7 @@ class MotionMarkActionTest : VimOptionTestCase(IjOptionConstants.ideamarks) {
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideamarks, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test simple add multiple marks on same line`() {
|
||||
val keys = injector.parser.parseKeys("mA" + "mB" + "mC")
|
||||
val text = """
|
||||
@ -74,6 +77,7 @@ class MotionMarkActionTest : VimOptionTestCase(IjOptionConstants.ideamarks) {
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideamarks, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test move to another line`() {
|
||||
val keys = injector.parser.parseKeys("mAjj" + "mA")
|
||||
val text = """
|
||||
@ -90,6 +94,7 @@ class MotionMarkActionTest : VimOptionTestCase(IjOptionConstants.ideamarks) {
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideamarks, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test simple system mark`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
@ -100,14 +105,15 @@ class MotionMarkActionTest : VimOptionTestCase(IjOptionConstants.ideamarks) {
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
myFixture.project.createLineBookmark(myFixture.editor, 2, 'A')
|
||||
fixture.project.createLineBookmark(fixture.editor, 2, 'A')
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
val vimMarks = injector.markService.getAllGlobalMarks()
|
||||
TestCase.assertEquals(1, vimMarks.size)
|
||||
TestCase.assertEquals('A', vimMarks.first().key)
|
||||
kotlin.test.assertEquals(1, vimMarks.size)
|
||||
kotlin.test.assertEquals('A', vimMarks.first().key)
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IjOptionConstants.ideamarks, OptionValueType.NUMBER, "1"))
|
||||
@Test
|
||||
fun `test system mark move to another line`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
@ -119,25 +125,25 @@ class MotionMarkActionTest : VimOptionTestCase(IjOptionConstants.ideamarks) {
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
|
||||
val bookmark = myFixture.project.createLineBookmark(myFixture.editor, 2, 'A')
|
||||
val bookmark = fixture.project.createLineBookmark(fixture.editor, 2, 'A')
|
||||
|
||||
BookmarksManager.getInstance(myFixture.project)?.remove(bookmark!!)
|
||||
myFixture.project.createLineBookmark(myFixture.editor, 4, 'A')
|
||||
BookmarksManager.getInstance(fixture.project)?.remove(bookmark!!)
|
||||
fixture.project.createLineBookmark(fixture.editor, 4, 'A')
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
val vimMarks = injector.markService.getAllGlobalMarks()
|
||||
TestCase.assertEquals(1, vimMarks.size)
|
||||
kotlin.test.assertEquals(1, vimMarks.size)
|
||||
val mark = vimMarks.first()
|
||||
TestCase.assertEquals('A', mark.key)
|
||||
TestCase.assertEquals(4, mark.line)
|
||||
kotlin.test.assertEquals('A', mark.key)
|
||||
kotlin.test.assertEquals(4, mark.line)
|
||||
}
|
||||
|
||||
private fun checkMarks(vararg marks: Pair<Char, Int>) {
|
||||
val project = myFixture.project
|
||||
val project = fixture.project
|
||||
val validBookmarks = BookmarksManager.getInstance(project)!!.bookmarks.sortedBy { it.mnemonic(project) }
|
||||
assertEquals(marks.size, validBookmarks.size)
|
||||
kotlin.test.assertEquals(marks.size, validBookmarks.size)
|
||||
marks.sortedBy { it.first }.forEachIndexed { index, (mn, line) ->
|
||||
assertEquals(mn, validBookmarks[index].mnemonic(project))
|
||||
assertEquals(line, (validBookmarks[index] as LineBookmark).line)
|
||||
kotlin.test.assertEquals(mn, validBookmarks[index].mnemonic(project))
|
||||
kotlin.test.assertEquals(line, (validBookmarks[index] as LineBookmark).line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user