-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue when wrap paragraph was done in the last line.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...s/org.python.pydev.core/tests/org/python/pydev/core/wrap_paragraph/WrapParagraphTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.python.pydev.core.wrap_paragraph; | ||
|
||
import org.eclipse.jface.text.BadLocationException; | ||
import org.eclipse.jface.text.Document; | ||
import org.eclipse.jface.text.IDocument; | ||
import org.eclipse.text.edits.MalformedTreeException; | ||
import org.eclipse.text.edits.ReplaceEdit; | ||
import org.python.pydev.core.docutils.PySelection; | ||
import org.python.pydev.shared_core.string.StringUtils; | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class WrapParagraphTest extends TestCase { | ||
|
||
public void testParagrapher() throws MalformedTreeException, BadLocationException { | ||
String txt = "# aaaa bbbb ccccc ddddd"; | ||
IDocument doc = new Document(txt); | ||
PySelection ps = new PySelection(doc); | ||
Paragrapher p = new Paragrapher(ps, 12); | ||
assertNull(p.getValidErrorInPos()); | ||
ReplaceEdit replaceEdit = p.getReplaceEdit(); | ||
replaceEdit.apply(doc); | ||
assertEquals("# aaaa bbbb\n" | ||
+ "# ccccc\n" | ||
+ "# ddddd", StringUtils.replaceNewLines(doc.get(), "\n")); | ||
|
||
} | ||
|
||
public void testParagrapher2() throws MalformedTreeException, BadLocationException { | ||
String txt = "# aaaa bbbb\n# ccccc ddddd"; | ||
IDocument doc = new Document(txt); | ||
PySelection ps = new PySelection(doc); | ||
Paragrapher p = new Paragrapher(ps, 12); | ||
assertNull(p.getValidErrorInPos()); | ||
ReplaceEdit replaceEdit = p.getReplaceEdit(); | ||
replaceEdit.apply(doc); | ||
assertEquals("# aaaa bbbb\n" | ||
+ "# ccccc\n" | ||
+ "# ddddd", StringUtils.replaceNewLines(doc.get(), "\n")); | ||
|
||
} | ||
|
||
public void testParagrapher3() throws MalformedTreeException, BadLocationException { | ||
String txt = "'''\naaaa bbbb\nccccc ddddd eeee\n'''"; | ||
IDocument doc = new Document(txt); | ||
PySelection ps = new PySelection(doc, 5); | ||
Paragrapher p = new Paragrapher(ps, 12); | ||
assertNull(p.getValidErrorInPos()); | ||
ReplaceEdit replaceEdit = p.getReplaceEdit(); | ||
replaceEdit.apply(doc); | ||
assertEquals("'''\n" | ||
+ "aaaa bbbb\n" | ||
+ "ccccc ddddd\n" | ||
+ "eeee\n" | ||
+ "'''", StringUtils.replaceNewLines(doc.get(), "\n")); | ||
|
||
} | ||
|
||
} |