From e311373524831258acd0effb72e212e74eae72de Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 7 Sep 2010 20:57:28 +0400 Subject: [PATCH] smart indent on paste for Python (PY-208) --- python/src/META-INF/python-plugin-common.xml | 2 ++ python/testData/copyPaste/Indent1.after.py | 3 +++ python/testData/copyPaste/Indent1.dst.py | 2 ++ python/testData/copyPaste/Indent1.src.py | 4 +++ python/testData/copyPaste/Indent2.after.py | 3 +++ python/testData/copyPaste/Indent2.dst.py | 2 ++ python/testData/copyPaste/Indent2.src.py | 4 +++ .../com/jetbrains/python/PyCopyPasteTest.java | 26 +++++++++++++++++++ 8 files changed, 46 insertions(+) create mode 100644 python/testData/copyPaste/Indent1.after.py create mode 100644 python/testData/copyPaste/Indent1.dst.py create mode 100644 python/testData/copyPaste/Indent1.src.py create mode 100644 python/testData/copyPaste/Indent2.after.py create mode 100644 python/testData/copyPaste/Indent2.dst.py create mode 100644 python/testData/copyPaste/Indent2.src.py create mode 100644 python/testSrc/com/jetbrains/python/PyCopyPasteTest.java diff --git a/python/src/META-INF/python-plugin-common.xml b/python/src/META-INF/python-plugin-common.xml index db5458eb6f5b..c618de4fc70e 100644 --- a/python/src/META-INF/python-plugin-common.xml +++ b/python/src/META-INF/python-plugin-common.xml @@ -175,6 +175,8 @@ + + diff --git a/python/testData/copyPaste/Indent1.after.py b/python/testData/copyPaste/Indent1.after.py new file mode 100644 index 000000000000..b63a962cbafe --- /dev/null +++ b/python/testData/copyPaste/Indent1.after.py @@ -0,0 +1,3 @@ +def bar(): + x = 1 + y = 2 \ No newline at end of file diff --git a/python/testData/copyPaste/Indent1.dst.py b/python/testData/copyPaste/Indent1.dst.py new file mode 100644 index 000000000000..c5345302841c --- /dev/null +++ b/python/testData/copyPaste/Indent1.dst.py @@ -0,0 +1,2 @@ +def bar(): + \ No newline at end of file diff --git a/python/testData/copyPaste/Indent1.src.py b/python/testData/copyPaste/Indent1.src.py new file mode 100644 index 000000000000..b014df70f891 --- /dev/null +++ b/python/testData/copyPaste/Indent1.src.py @@ -0,0 +1,4 @@ +class C: + def foo(self): + x = 1 + y = 2 diff --git a/python/testData/copyPaste/Indent2.after.py b/python/testData/copyPaste/Indent2.after.py new file mode 100644 index 000000000000..b63a962cbafe --- /dev/null +++ b/python/testData/copyPaste/Indent2.after.py @@ -0,0 +1,3 @@ +def bar(): + x = 1 + y = 2 \ No newline at end of file diff --git a/python/testData/copyPaste/Indent2.dst.py b/python/testData/copyPaste/Indent2.dst.py new file mode 100644 index 000000000000..c5345302841c --- /dev/null +++ b/python/testData/copyPaste/Indent2.dst.py @@ -0,0 +1,2 @@ +def bar(): + \ No newline at end of file diff --git a/python/testData/copyPaste/Indent2.src.py b/python/testData/copyPaste/Indent2.src.py new file mode 100644 index 000000000000..9d884a863e58 --- /dev/null +++ b/python/testData/copyPaste/Indent2.src.py @@ -0,0 +1,4 @@ +class C: + def foo(self): + x = 1 + y = 2 diff --git a/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java b/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java new file mode 100644 index 000000000000..04334d8e85a0 --- /dev/null +++ b/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java @@ -0,0 +1,26 @@ +package com.jetbrains.python; + +import com.intellij.openapi.actionSystem.IdeActions; +import com.jetbrains.python.fixtures.PyLightFixtureTestCase; + +/** + * @author yole + */ +public class PyCopyPasteTest extends PyLightFixtureTestCase { + public void testIndent1() { + doTest(); + } + + public void testIndent2() { + doTest(); + } + + private void doTest() { + String name = getTestName(false); + myFixture.configureByFile("copyPaste/" + name + ".src.py"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_COPY); + myFixture.configureByFile("copyPaste/"+ name + ".dst.py"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PASTE); + myFixture.checkResultByFile("copyPaste/" + name + ".after.py"); + } +}