1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-02-27 17:45:59 +01:00

VIM-3060 Clipboard interaction stopped working

Fixed issue and tests (for Linux)
This commit is contained in:
filipp 2023-09-07 02:39:23 +03:00
parent c4a773e72d
commit 74a710c5e8
8 changed files with 62 additions and 61 deletions
src/test/java/org/jetbrains/plugins/ideavim
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/register

View File

@ -161,7 +161,7 @@ class PutViaIdeaTest : VimTestCase() {
// For this particular test, we want to set exact this type of transferable
CopyPasteManagerEx.getInstance().setContents(StringSelection("Hello"))
typeText("\"*p", "\"*p")
typeText("\"+p", "\"+p")
val after = """
A Discovery
HelloHello

View File

@ -121,8 +121,8 @@ class PutVisualTextActionTest : VimTestCase() {
fun `test put visual text multicaret clipboard register`() {
val before = "${c}I found ${c}it in a ${c}legendary land"
configureByText(before)
injector.registerGroup.storeText('*', "legendary", SelectionType.CHARACTER_WISE)
typeText(injector.parser.parseKeys("ve" + "\"*p"))
injector.registerGroup.storeText('+', "legendary", SelectionType.CHARACTER_WISE)
typeText(injector.parser.parseKeys("ve" + "\"+p"))
val after = "legendar${c}y legendar${c}y in a legendar${c}y land"
assertState(after)
}
@ -296,8 +296,8 @@ class PutVisualTextActionTest : VimTestCase() {
${c}hard by the torrent of a mountain pass.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("ve" + "\"*p"))
injector.registerGroup.storeText('+', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("ve" + "\"+p"))
val after = """
A Discovery
@ -356,8 +356,8 @@ class PutVisualTextActionTest : VimTestCase() {
${c}hard by the$c torrent of a mountain pass.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("ve" + "\"*p"))
injector.registerGroup.storeText('+', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("ve" + "\"+p"))
val after = """
A Discovery
@ -416,8 +416,8 @@ class PutVisualTextActionTest : VimTestCase() {
${c}hard by the$c torrent of a mountain pass.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("ve" + "2\"*p"))
injector.registerGroup.storeText('+', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("ve" + "2\"+p"))
val after = """
A Discovery
@ -604,9 +604,9 @@ class PutVisualTextActionTest : VimTestCase() {
the dingy ${c}underside, the checquered fringe.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
injector.registerGroup.storeText('+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
// VimPlugin.getRegister().storeText(editor.vim, editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false)
typeText(injector.parser.parseKeys("ve" + "\"*p"))
typeText(injector.parser.parseKeys("ve" + "\"+p"))
val after = """
A Discovery
@ -775,8 +775,8 @@ class PutVisualTextActionTest : VimTestCase() {
hard by the ${c}torrent of a mountain pass.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "Discovery", SelectionType.CHARACTER_WISE)
typeText(injector.parser.parseKeys("V" + "\"*p"))
injector.registerGroup.storeText('+', "Discovery", SelectionType.CHARACTER_WISE)
typeText(injector.parser.parseKeys("V" + "\"+p"))
val after = """
A Discovery
@ -847,8 +847,8 @@ class PutVisualTextActionTest : VimTestCase() {
hard by the ${c}torrent of a mountain pass.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "Discovery", SelectionType.CHARACTER_WISE)
typeText(injector.parser.parseKeys("V" + "\"*p"))
injector.registerGroup.storeText('+', "Discovery", SelectionType.CHARACTER_WISE)
typeText(injector.parser.parseKeys("V" + "\"+p"))
val after = """
A Discovery
@ -1011,8 +1011,8 @@ class PutVisualTextActionTest : VimTestCase() {
hard by the ${c}torrent of a mountain pass.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("V" + "\"*p"))
injector.registerGroup.storeText('+', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("V" + "\"+p"))
val after = """
A Discovery
@ -1083,8 +1083,8 @@ class PutVisualTextActionTest : VimTestCase() {
hard by the ${c}torrent of a mountain pass.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("V" + "\"*p"))
injector.registerGroup.storeText('+', "A Discovery\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("V" + "\"+p"))
val after = """
A Discovery
@ -1353,8 +1353,8 @@ class PutVisualTextActionTest : VimTestCase() {
the dingy ${c}underside, the checquered fringe.
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
typeText(injector.parser.parseKeys("V" + "\"*p"))
injector.registerGroup.storeText('+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
typeText(injector.parser.parseKeys("V" + "\"+p"))
val after = """
A Discovery

View File

@ -244,8 +244,8 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
""".trimIndent()
configureByText(before)
injector.registerGroup.storeText('*', "zxcvbn\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("vl" + "\"*gp"))
injector.registerGroup.storeText('+', "zxcvbn\n", SelectionType.LINE_WISE)
typeText(injector.parser.parseKeys("vl" + "\"+gp"))
val after = """
q
zxcvbn

View File

@ -19,30 +19,7 @@ import org.jetbrains.plugins.ideavim.impl.VimOption
@TraceOptions(TestOptionConstants.clipboard)
class YankAndPutTest : VimTestCase() {
@OptionTest(VimOption(TestOptionConstants.clipboard, limitedValues = [OptionConstants.clipboard_unnamed]))
fun `test yank to number register with unnamed`() {
val before = """
I ${c}found it in a legendary land
consectetur adipiscing elit
""".trimIndent()
configureByText(before)
// Select and yank first word
typeText(injector.parser.parseKeys("vey"))
// Replace second word
typeText(injector.parser.parseKeys("wvep"))
// Replace previous word
typeText(injector.parser.parseKeys("bbvep"))
assertState(
"""
I it found in a legendary land
consectetur adipiscing elit
""".trimIndent(),
)
}
@OptionTest(VimOption(TestOptionConstants.clipboard, limitedValues = [OptionConstants.clipboard_unnamedplus]))
@TestWithoutPrimaryClipboard
fun `test yank to number register with unnamedplus`() {
val before = """
I ${c}found it in a legendary land
@ -64,7 +41,30 @@ class YankAndPutTest : VimTestCase() {
)
}
@OptionTest(VimOption(TestOptionConstants.clipboard, limitedValues = [OptionConstants.clipboard_unnamed + "," + OptionConstants.clipboard_ideaput]))
@OptionTest(VimOption(TestOptionConstants.clipboard, limitedValues = [OptionConstants.clipboard_unnamed]))
@TestWithoutPrimaryClipboard
fun `test yank to number register with unnamed`() {
val before = """
I ${c}found it in a legendary land
consectetur adipiscing elit
""".trimIndent()
configureByText(before)
// Select and yank first word
typeText(injector.parser.parseKeys("vey"))
// Replace second word
typeText(injector.parser.parseKeys("wvep"))
// Replace previous word
typeText(injector.parser.parseKeys("bbvep"))
assertState(
"""
I it found in a legendary land
consectetur adipiscing elit
""".trimIndent(),
)
}
@OptionTest(VimOption(TestOptionConstants.clipboard, limitedValues = [OptionConstants.clipboard_unnamedplus + "," + OptionConstants.clipboard_ideaput]))
fun `test yank to number register with unnamedplus and ideaput`() {
val before = """
I ${c}found it in a legendary land

View File

@ -300,11 +300,12 @@ class RegistersCommandTest : VimTestCase() {
enterCommand("set clipboard&")
}
@Test
@TestWithPrimaryClipboard
fun `test list empty registers linux`() {
configureByText("")
enterCommand("registers")
assertExOutput("Type Name Content\n c \"+ ")
assertExOutput("Type Name Content\n c \"* ")
}
@TestWithPrimaryClipboard
@ -317,7 +318,7 @@ class RegistersCommandTest : VimTestCase() {
assertExOutput(
"""Type Name Content
| c "a ^IHello World^J^[
| c "+
| c "*
""".trimMargin(),
)
}
@ -412,8 +413,8 @@ class RegistersCommandTest : VimTestCase() {
| c "y Hello world y
| c "z Hello world z
| c "- s
| c "* clipboard content
| c "+ mall delete register
| c "* mall delete register
| c "+ clipboard content
| c ": ascii
| c "/ search pattern
""".trimMargin(),
@ -431,8 +432,8 @@ class RegistersCommandTest : VimTestCase() {
enterCommand("registers")
assertExOutput(
"""Type Name Content
| c "* clipboard content
| c "+ line 0
| c "* line 0
| c "+ clipboard content
""".trimMargin(),
)
}
@ -469,6 +470,7 @@ class RegistersCommandTest : VimTestCase() {
"""Type Name Content
| c "" line
| c "- line
| c "*
| c "+ line
| c ": set clipboard=unnamed,unnamedplus
""".trimMargin(),

View File

@ -551,12 +551,12 @@ class ReplaceWithRegisterTest : VimTestCase() {
}
@TestWithPrimaryClipboard
fun `test replace in visual with clipboard unnamedplus linux`() {
fun `test replace in visual with clipboard unnamed linux`() {
VimPlugin.getRegister().resetRegisters()
configureByText("one ${c}two three")
enterCommand("set clipboard+=unnamedplus")
injector.registerGroup.storeText('+', "four")
enterCommand("set clipboard+=unnamed")
injector.registerGroup.storeText('*', "four")
typeText(injector.parser.parseKeys("vegr"))
assertState("one two three")

View File

@ -19,8 +19,8 @@ public object RegisterConstants {
public const val EXPRESSION_BUFFER_REGISTER: Char = '='
public const val CURRENT_FILENAME_REGISTER: Char = '%'
public const val CLIPBOARD_REGISTER: Char = '*'
public const val PRIMARY_REGISTER: Char = '+'
public const val CLIPBOARD_REGISTER: Char = '+'
public const val PRIMARY_REGISTER: Char = '*'
public const val CLIPBOARD_REGISTERS: String = CLIPBOARD_REGISTER.toString() + PRIMARY_REGISTER
public const val NUMBERED_REGISTERS: String = "0123456789"

View File

@ -74,15 +74,14 @@ public abstract class VimRegisterGroupBase : VimRegisterGroup {
private val onClipboardChanged: () -> Unit = {
val clipboardOptionValue = injector.globalOptions().clipboard
defaultRegisterChar = when {
"unnamedplus" in clipboardOptionValue -> {
"unnamedplus" in clipboardOptionValue -> CLIPBOARD_REGISTER
"unnamed" in clipboardOptionValue -> {
if (isPrimaryRegisterSupported()) {
PRIMARY_REGISTER
} else {
CLIPBOARD_REGISTER
}
}
"unnamed" in clipboardOptionValue -> CLIPBOARD_REGISTER
else -> UNNAMED_REGISTER
}
lastRegisterChar = defaultRegisterChar