From 9bc2ec7d8a13e4c7841178cc2ba7c5df41e40e8f Mon Sep 17 00:00:00 2001 From: Valery Isaev Date: Mon, 13 Apr 2020 15:02:49 +0300 Subject: [PATCH] Fix #VIM-1994 --- .../maddyhome/idea/vim/group/copy/PutGroup.kt | 2 +- .../ideavim/action/copy/PutViaIdeaTest.kt | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/com/maddyhome/idea/vim/group/copy/PutGroup.kt b/src/com/maddyhome/idea/vim/group/copy/PutGroup.kt index 226c965b01..8503fbfbae 100644 --- a/src/com/maddyhome/idea/vim/group/copy/PutGroup.kt +++ b/src/com/maddyhome/idea/vim/group/copy/PutGroup.kt @@ -144,7 +144,7 @@ class PutGroup { if (data.textData.typeInRegister.isLine && text.isNotEmpty() && text.last() != '\n') text += '\n' - if (data.textData.typeInRegister.isChar && text.lastOrNull() == '\n' && data.visualSelection?.typeInEditor?.isLine != true) text = text.dropLast(1) + if (data.textData.typeInRegister.isChar && text.lastOrNull() == '\n' && data.visualSelection?.typeInEditor?.isLine == false) text = text.dropLast(1) return ProcessedTextData(text, data.textData.typeInRegister, data.textData.transferableData) } diff --git a/test/org/jetbrains/plugins/ideavim/action/copy/PutViaIdeaTest.kt b/test/org/jetbrains/plugins/ideavim/action/copy/PutViaIdeaTest.kt index 612ae13763..21e5062c0d 100644 --- a/test/org/jetbrains/plugins/ideavim/action/copy/PutViaIdeaTest.kt +++ b/test/org/jetbrains/plugins/ideavim/action/copy/PutViaIdeaTest.kt @@ -83,4 +83,29 @@ class PutViaIdeaTest : VimTestCase() { typeText(StringHelper.parseKeys("ve", "p")) assertEquals(sizeBefore, CopyPasteManager.getInstance().allContents.size) } + + fun `test insert block with newline`() { + val before = """ + A Discovery + $c + I found it in a legendary land + + hard by the torrent of a mountain pass. + """.trimIndent() + configureByText(before) + + VimPlugin.getRegister().storeText(myFixture.editor, before rangeOf "\nI found it in a legendary land\n", SelectionType.CHARACTER_WISE, false) + + typeText(StringHelper.parseKeys("p")) + val after = """ + A Discovery + + I found it in a legendary land + + I found it in a legendary land + + hard by the torrent of a mountain pass. + """.trimIndent() + myFixture.checkResult(after) + } } \ No newline at end of file