From edc5e4ea3831cafcc6716239163520dd70ef82db Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Mon, 9 Dec 2013 13:30:03 +0400 Subject: [PATCH] fixed IDEA-111701 Emacs: pressing Ctrl+k several times should add lines to muti-line buffer (regression for IDEA-18764, broken in IDEA-111275) moveToLogicalPosition and moveToVisualPosition in CaretModel sometimes doesn't actually move caret and used to perform softwrap adjustment on document changes --- .../openapi/editor/impl/CaretModelImpl.java | 4 ++-- .../editor/actions/KillToWordEndActionTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java index 762aaaa807d4..b34f2927f7e0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java @@ -152,7 +152,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, if (myReportCaretMoves) { LogMessageEx.error(LOG, "Unexpected caret move request"); } - if (!myEditor.isStickySelection()) { + if (!myEditor.isStickySelection() && !pos.equals(myVisibleCaret)) { CopyPasteManager.getInstance().stopKillRings(); } @@ -441,7 +441,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, if (myReportCaretMoves) { LogMessageEx.error(LOG, "Unexpected caret move request"); } - if (!myEditor.isStickySelection()) { + if (!myEditor.isStickySelection() && !pos.equals(myLogicalCaret)) { CopyPasteManager.getInstance().stopKillRings(); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/KillToWordEndActionTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/KillToWordEndActionTest.java index 83340d0b8102..31b8aaae3de5 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/KillToWordEndActionTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/KillToWordEndActionTest.java @@ -108,4 +108,17 @@ public class KillToWordEndActionTest extends LightPlatformCodeInsightTestCase { Object string = contents.getTransferData(DataFlavor.stringFlavor); assertEquals(" second", string); } + + public void testSubsequentKills() throws Exception { + String text = "first second third"; + configureFromFileText(getTestName(false) + ".txt", text); + killToWordEnd(); + killToWordEnd(); + checkResultByText(" third"); + + Transferable contents = CopyPasteManager.getInstance().getContents(); + assertTrue(contents instanceof KillRingTransferable); + Object string = contents.getTransferData(DataFlavor.stringFlavor); + assertEquals("first second", string); + } }