mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-02-25 02:46:01 +01:00
Fix multiple copy from unnamed clipboard
This commit is contained in:
parent
1466ad9bef
commit
85c8968d75
@ -24,9 +24,11 @@ Please note that the quality of EAP versions may at times be way below even
|
||||
usual beta standards.
|
||||
|
||||
## To Be Released
|
||||
|
||||
### Fixes:
|
||||
* [VIM-2400](https://youtrack.jetbrains.com/issue/VIM-2400) Fix vim script parser
|
||||
* [VIM-2401](https://youtrack.jetbrains.com/issue/VIM-2401) Exceptions occurred during execution of `map<expr>` are now shown in status bar
|
||||
* [VIM-2404](https://youtrack.jetbrains.com/issue/VIM-2404) Fix multiple pastes from unnamed clipboard
|
||||
|
||||
## 1.7.0, 2021-09-16
|
||||
|
||||
|
@ -51,6 +51,7 @@ import com.maddyhome.idea.vim.helper.fileSize
|
||||
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
|
||||
import com.maddyhome.idea.vim.option.ClipboardOptionsData
|
||||
import com.maddyhome.idea.vim.option.OptionsManager
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
@ -328,11 +329,12 @@ class PutGroup {
|
||||
val origContent: TextBlockTransferable = setClipboardText(text.text, text.transferableData)
|
||||
val allContentsAfter = CopyPasteManager.getInstance().allContents
|
||||
val sizeAfterInsert = allContentsAfter.size
|
||||
val firstItemAfter = allContentsAfter.firstOrNull()
|
||||
try {
|
||||
pasteProvider.performPaste(context)
|
||||
} finally {
|
||||
if (sizeBeforeInsert != sizeAfterInsert || firstItemBefore != firstItemAfter) {
|
||||
val textOnTop =
|
||||
((firstItemBefore as? TextBlockTransferable)?.getTransferData(DataFlavor.stringFlavor) as? String) != text.text
|
||||
if (sizeBeforeInsert != sizeAfterInsert || textOnTop) {
|
||||
// Sometimes inserted text replaces existing one. E.g. on insert with + or * register
|
||||
(CopyPasteManager.getInstance() as? CopyPasteManagerEx)?.run { removeContent(origContent) }
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ class UiTests {
|
||||
}
|
||||
}
|
||||
|
||||
testUnnamedClipboard(editor)
|
||||
testSelectAndRightClick(editor)
|
||||
testSelectTextWithMouseInGutter(editor)
|
||||
testSelectForthAndBack(editor)
|
||||
@ -121,6 +122,39 @@ class UiTests {
|
||||
}
|
||||
}
|
||||
|
||||
private fun IdeaFrame.testUnnamedClipboard(editor: Editor) {
|
||||
keyboard {
|
||||
enterText(":set clipboard+=unnamed")
|
||||
enter()
|
||||
|
||||
enterText("gg")
|
||||
enterText("yy")
|
||||
enterText("jyy")
|
||||
enterText("jyy")
|
||||
enterText("p")
|
||||
enterText("p")
|
||||
enterText("p")
|
||||
}
|
||||
|
||||
assertEquals(
|
||||
"""
|
||||
One Two
|
||||
Three Four
|
||||
Five
|
||||
Five
|
||||
Five
|
||||
Five
|
||||
|
||||
""".trimIndent(),
|
||||
editor.text
|
||||
)
|
||||
|
||||
keyboard {
|
||||
enterText(":set clipboard-=unnamed")
|
||||
enter()
|
||||
}
|
||||
}
|
||||
|
||||
private fun IdeaFrame.wrapWithIf(editor: Editor) {
|
||||
editor.findText("System").click()
|
||||
remoteRobot.invokeActionJs("SurroundWith")
|
||||
|
Loading…
Reference in New Issue
Block a user