diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy index ba85483ca036..5c0a6ccd18b5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy @@ -443,6 +443,26 @@ line to paste #1 doTest(before, toPaste, expected, TestFileType.TEXT) } + def testPlainTextPasteWithCompleteReplacement() { + def before = '''\ + line1 + line2\ +''' + + def toPaste = + '''\ +line to paste #1 +line to paste #2 +''' + + + def expected = '''\ +line to paste #1 +line to paste #2 +''' + doTest(before, toPaste, expected, TestFileType.TEXT) + } + def doTest(before, toPaste, expected, fileType = TestFileType.JAVA) { configureFromFileText("${getTestName(false)}.$fileType.extension", before) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java index 96bf7a6fe287..2eacc170c13b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java @@ -342,11 +342,8 @@ public class PasteHandler extends EditorActionHandler { Arrays.fill(fill, ' '); String indentString = new String(fill); - for ( + for (; linesToAdjustIndent > 0; linesToAdjustIndent--) { int lineStartOffset = document.getLineStartOffset(++line); - linesToAdjustIndent > 0; - lineStartOffset = document.getLineStartOffset(++line), linesToAdjustIndent--) - { document.insertString(lineStartOffset, indentString); } }