Skip to content

Commit

Permalink
Merge pull request #233
Browse files Browse the repository at this point in the history
Fix #VIM-1994
  • Loading branch information
AlexPl292 authored May 6, 2020
2 parents fb04e83 + 9bc2ec7 commit 61677aa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/com/maddyhome/idea/vim/group/copy/PutGroup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
25 changes: 25 additions & 0 deletions test/org/jetbrains/plugins/ideavim/action/copy/PutViaIdeaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 61677aa

Please sign in to comment.