when joining comments, we skipped over whitespace to the left of caret twice, which caused characters to be deleted (PY-7286)

This commit is contained in:
Dmitry Jemerov
2012-08-23 13:53:48 +02:00
parent 0d9f715982
commit 692907014e
5 changed files with 7 additions and 6 deletions
@@ -420,11 +420,7 @@ public class PyJoinLinesHandler implements JoinRawLinesHandlerDelegate {
int last = right_range.getEndOffset();
while (pos < last && " \t".indexOf(text.charAt(pos)) >= 0) pos += 1;
int right = pos - initial_pos + 1; // account for the '#'
initial_pos = req.leftElem().getTextRange().getEndOffset() - 1;
pos = initial_pos;
while (" \t".indexOf(text.charAt(pos)) >= 0) pos -=1; // we'll end up at '#' if nothing else
int left = initial_pos - pos;
return new Result(" ", 0, left, right);
return new Result(" ", 0, 0, right);
}
return null;
}
@@ -0,0 +1 @@
# has the
@@ -0,0 +1,2 @@
# has <caret>
# the
@@ -61,6 +61,7 @@ public class PyJoinLinesTest extends PyTestCase {
public void testTuple() { doTest(); }
public void testTupleRPar() { doTest(); }
public void testTwoComments() { doTest(); }
public void testTwoComments2() { doTest(); } // PY-7286
public void testTwoStatements() { doTest(); }
public void testStringWithSlash() { doTest(); }
public void testListOfStrings() { doTest(); }
@@ -98,7 +98,8 @@ public class PythonAllTestsSuite {
PyMissingConstructorTest.class,
PyPropertyAccessInspectionTest.class,
Jinja2ParserTest.class,
DjangoTemplateParserTest.class
DjangoTemplateParserTest.class,
PyJoinLinesTest.class
};
public static TestSuite suite() {