1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-10 15:40:37 +02:00

Fix failing tests

(please)
This commit is contained in:
filipp 2023-08-03 13:39:33 +03:00
parent e2c0d59e3a
commit 4188e636f3
3 changed files with 125 additions and 116 deletions
src/test/java/org/jetbrains/plugins/ideavim
ex/implementation/commands
extension/replacewithregister
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/register

View File

@ -8,6 +8,7 @@
package org.jetbrains.plugins.ideavim.ex.implementation.commands
import com.intellij.testFramework.SkipInHeadlessEnvironment
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.SelectionType
@ -26,14 +27,6 @@ class RegistersCommandTest : VimTestCase() {
assertExOutput("Type Name Content\n")
}
@Test
@EnabledOnOs(OS.LINUX)
fun `test list empty registers linux`() {
configureByText("")
enterCommand("registers")
assertExOutput("Type Name Content\n c \"+ ")
}
@Test
fun `test argument filters output`() {
configureByText("")
@ -122,22 +115,6 @@ class RegistersCommandTest : VimTestCase() {
)
}
@Test
@EnabledOnOs(OS.LINUX)
fun `test correctly encodes non printable characters linux`() {
configureByText("")
VimPlugin.getRegister().setKeys('a', injector.parser.parseKeys("<Tab>Hello<Space>World<CR><Esc>"))
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "a ^IHello World^J^[
| c "+
""".trimMargin(),
)
}
@Test
fun `test display synonym for registers command`() {
configureByText("")
@ -254,6 +231,110 @@ class RegistersCommandTest : VimTestCase() {
)
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test clipboard registers are not duplicated`() {
configureByText("<caret>line 0 ")
injector.registerGroup.saveRegister('+', Register('+', SelectionType.LINE_WISE, "Lorem ipsum dolor", mutableListOf()))
injector.clipboardManager.setClipboardText("clipboard content", "clipboard content", emptyList())
typeText("V<Esc>")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "* clipboard content
""".trimMargin(),
)
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test registers after yank with unnamed and unnamedplus`() {
configureByText("<caret>line 0 ")
enterCommand("set clipboard=unnamed,unnamedplus")
typeText("ye")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "" line
| c "0 line
| c "* line
| c ": set clipboard=unnamed,unnamedplus
""".trimMargin(),
)
enterCommand("set clipboard&")
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test registers after delete with unnamed and unnamedplus`() {
configureByText("<caret>line 0 ")
enterCommand("set clipboard=unnamed,unnamedplus")
typeText("de")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "" line
| c "- line
| c "* line
| c ": set clipboard=unnamed,unnamedplus
""".trimMargin(),
)
enterCommand("set clipboard&")
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test registers for nonlinux with unnamedplus`() {
configureByText("<caret>line 0 ")
enterCommand("set clipboard=unnamedplus")
typeText("de")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "" line
| c "- line
| c "* line
| c ": set clipboard=unnamedplus
""".trimMargin(),
)
enterCommand("set clipboard&")
}
}
@SkipInHeadlessEnvironment
class RegistersCommandLinuxTest : VimTestCase() {
@Test
@EnabledOnOs(OS.LINUX)
fun `test list empty registers linux`() {
configureByText("")
enterCommand("registers")
assertExOutput("Type Name Content\n c \"+ ")
}
@Test
@EnabledOnOs(OS.LINUX)
fun `test correctly encodes non printable characters linux`() {
configureByText("")
VimPlugin.getRegister().setKeys('a', injector.parser.parseKeys("<Tab>Hello<Space>World<CR><Esc>"))
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "a ^IHello World^J^[
| c "+
""".trimMargin(),
)
}
@Test
@EnabledOnOs(OS.LINUX)
fun `test list all registers in correct order linux`() {
@ -371,23 +452,6 @@ class RegistersCommandTest : VimTestCase() {
)
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test clipboard registers are not duplicated`() {
configureByText("<caret>line 0 ")
injector.registerGroup.saveRegister('+', Register('+', SelectionType.LINE_WISE, "Lorem ipsum dolor", mutableListOf()))
injector.clipboardManager.setClipboardText("clipboard content", "clipboard content", emptyList())
typeText("V<Esc>")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "* clipboard content
""".trimMargin(),
)
}
@Test
@EnabledOnOs(OS.LINUX)
fun `test registers after yank with unnamed and unnamedplus linux`() {
@ -409,26 +473,6 @@ class RegistersCommandTest : VimTestCase() {
enterCommand("set clipboard&")
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test registers after yank with unnamed and unnamedplus`() {
configureByText("<caret>line 0 ")
enterCommand("set clipboard=unnamed,unnamedplus")
typeText("ye")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "" line
| c "0 line
| c "* line
| c ": set clipboard=unnamed,unnamedplus
""".trimMargin(),
)
enterCommand("set clipboard&")
}
@Test
@EnabledOnOs(OS.LINUX)
fun `test registers after delete with unnamed and unnamedplus linux`() {
@ -448,44 +492,4 @@ class RegistersCommandTest : VimTestCase() {
)
enterCommand("set clipboard&")
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test registers after delete with unnamed and unnamedplus`() {
configureByText("<caret>line 0 ")
enterCommand("set clipboard=unnamed,unnamedplus")
typeText("de")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "" line
| c "- line
| c "* line
| c ": set clipboard=unnamed,unnamedplus
""".trimMargin(),
)
enterCommand("set clipboard&")
}
@Test
@EnabledOnOs(OS.WINDOWS, OS.MAC)
fun `test registers for nonlinux with unnamedplus`() {
configureByText("<caret>line 0 ")
enterCommand("set clipboard=unnamedplus")
typeText("de")
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "" line
| c "- line
| c "* line
| c ": set clipboard=unnamedplus
""".trimMargin(),
)
enterCommand("set clipboard&")
}
}

View File

@ -8,6 +8,7 @@
package org.jetbrains.plugins.ideavim.extension.replacewithregister
import com.intellij.testFramework.SkipInHeadlessEnvironment
import com.intellij.testFramework.UsefulTestCase.assertContainsElements
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.injector
@ -521,20 +522,6 @@ class ReplaceWithRegisterTest : VimTestCase() {
assertMode(VimStateMachine.Mode.COMMAND)
}
@Test
@EnabledOnOs(OS.LINUX)
fun `test replace in visual with clipboard unnamedplus linux`() {
VimPlugin.getRegister().resetRegisters()
configureByText("one ${c}two three")
enterCommand("set clipboard+=unnamedplus")
injector.registerGroup.storeText('+', "four")
typeText(injector.parser.parseKeys("vegr"))
assertState("one two three")
enterCommand("set clipboard&")
}
@Test
fun `test replace in visual with clipboard unnamed`() {
VimPlugin.getRegister().resetRegisters()
@ -565,3 +552,20 @@ class ReplaceWithRegisterTest : VimTestCase() {
enterCommand("set clipboard&")
}
}
@SkipInHeadlessEnvironment
class ReplaceWithRegisterLinuxTest : VimTestCase() {
@Test
@EnabledOnOs(OS.LINUX)
fun `test replace in visual with clipboard unnamedplus linux`() {
VimPlugin.getRegister().resetRegisters()
configureByText("one ${c}two three")
enterCommand("set clipboard+=unnamedplus")
injector.registerGroup.storeText('+', "four")
typeText(injector.parser.parseKeys("vegr"))
assertState("one two three")
enterCommand("set clipboard&")
}
}

View File

@ -33,6 +33,7 @@ import com.maddyhome.idea.vim.register.RegisterConstants.SMALL_DELETION_REGISTER
import com.maddyhome.idea.vim.register.RegisterConstants.UNNAMED_REGISTER
import com.maddyhome.idea.vim.register.RegisterConstants.VALID_REGISTERS
import com.maddyhome.idea.vim.register.RegisterConstants.WRITABLE_REGISTERS
import java.awt.GraphicsEnvironment
import javax.swing.KeyStroke
public abstract class VimRegisterGroupBase : VimRegisterGroup {
@ -377,7 +378,7 @@ public abstract class VimRegisterGroupBase : VimRegisterGroup {
}
private fun isPrimaryRegisterSupported(): Boolean {
return injector.systemInfoService.isXWindow
return !GraphicsEnvironment.isHeadless() && injector.systemInfoService.isXWindow
}
private fun setSystemPrimaryRegisterText(text: String, rawText: String, transferableData: List<Any>) {