don't try to preserve indentation when pasting single-line fragment (PY-1815)
authorDmitry Jemerov <yole@jetbrains.com>
Wed, 15 Sep 2010 17:29:06 +0000 (21:29 +0400)
committerDmitry Jemerov <yole@jetbrains.com>
Wed, 15 Sep 2010 18:11:57 +0000 (22:11 +0400)
platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteIndentProcessor.java

index fb158f8d93bb8f7087a1136fc4d44922db129d7c..235e5b2b6180ee2a66b8643a3ae5ff597eb3b9e9 100644 (file)
@@ -124,6 +124,11 @@ public class CopyPasteIndentProcessor implements CopyPastePostProcessor<IndentTr
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       @Override
       public void run() {
+        String pastedText = document.getText(new TextRange(bounds.getStartOffset(), bounds.getEndOffset()));
+        if (pastedText.trim().indexOf("\n") < 0) {
+          // don't indent single-line text
+          return;
+        }
         int startLine = document.getLineNumber(bounds.getStartOffset());
         int endLine = document.getLineNumber(bounds.getEndOffset());
         int startLineStart = document.getLineStartOffset(startLine);