From 981c7a0021f34e25e2f82f1fe4ca08958a4e8710 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 18 Sep 2012 17:43:20 +0400 Subject: [PATCH] fixed PY-7599 Conflict with bin/pycharm64.exe.vmoptions upgrading from PyCharm 2.6.1 to 2.6.2 --- .../com/jetbrains/python/editor/PythonCopyPasteProcessor.java | 2 +- python/testData/copyPaste/BeginningOfFile.after.py | 3 +++ python/testData/copyPaste/BeginningOfFile.dst.py | 2 ++ python/testData/copyPaste/BeginningOfFile.src.py | 3 +++ python/testSrc/com/jetbrains/python/PyCopyPasteTest.java | 4 ++++ 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 python/testData/copyPaste/BeginningOfFile.after.py create mode 100644 python/testData/copyPaste/BeginningOfFile.dst.py create mode 100644 python/testData/copyPaste/BeginningOfFile.src.py diff --git a/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java b/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java index 137d87eea46a..8ae2ade549b6 100644 --- a/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java +++ b/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java @@ -113,7 +113,7 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor { newText = new String(text); // to indent correctly (see PasteHandler) } - if (element instanceof PsiWhiteSpace && + if ((element instanceof PsiWhiteSpace || element.getTextOffset() == 0) && (StringUtil.countChars(element.getText(), '\n') <= 2 && !StringUtil.isEmptyOrSpaces(text))) { newText += "\n"; } diff --git a/python/testData/copyPaste/BeginningOfFile.after.py b/python/testData/copyPaste/BeginningOfFile.after.py new file mode 100644 index 000000000000..663a4618bbc9 --- /dev/null +++ b/python/testData/copyPaste/BeginningOfFile.after.py @@ -0,0 +1,3 @@ +a = 1 +b = 2 +a = 1 \ No newline at end of file diff --git a/python/testData/copyPaste/BeginningOfFile.dst.py b/python/testData/copyPaste/BeginningOfFile.dst.py new file mode 100644 index 000000000000..991d8ef2dab4 --- /dev/null +++ b/python/testData/copyPaste/BeginningOfFile.dst.py @@ -0,0 +1,2 @@ +b = 2 +a = 1 \ No newline at end of file diff --git a/python/testData/copyPaste/BeginningOfFile.src.py b/python/testData/copyPaste/BeginningOfFile.src.py new file mode 100644 index 000000000000..9f58dbcebdbf --- /dev/null +++ b/python/testData/copyPaste/BeginningOfFile.src.py @@ -0,0 +1,3 @@ +b = 2 +a = 1 + \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java b/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java index 30e63e9a6b01..2c515b000a74 100644 --- a/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java +++ b/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java @@ -255,6 +255,10 @@ public class PyCopyPasteTest extends PyTestCase { doTest(); } + public void testBeginningOfFile() { //PY-7524 + doTest(); + } + private void doTest() { String name = getTestName(false);