Restored for consistency: "if line comment prefix is followed by a single space, uncomment line action deletes that space (PY-980)""

This reverts commit 0de5b6dd19224ee3d3992e92a04a9df24aa4066f.
This commit is contained in:
Roman Chernyatchik
2010-06-24 16:43:11 +04:00
committed by Dennis Ushakov
parent df24cfb010
commit ef275977d8
@@ -464,8 +464,15 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
boolean commented = CharArrayUtil.regionMatches(chars, startOffset, prefix) ||
(skipNewLine = prefix.endsWith(" ") && CharArrayUtil.regionMatches(chars, startOffset, prefix.trim() + "\n"));
assert commented;
int position = 0;//text.indexOf(prefix);
myDocument.deleteString(position + startOffset , position + startOffset + (skipNewLine? prefix.trim().length():prefix.length()));
int charsToDelete = skipNewLine ? prefix.trim().length() : prefix.length();
int theEnd = endOffset > 0 ? endOffset : chars.length();
// if there's exactly one space after line comment prefix and before the text that follows in the same line, delete the space too
if (startOffset + charsToDelete < theEnd-2 && chars.charAt(startOffset+charsToDelete) == ' ' &&
chars.charAt(startOffset+charsToDelete+1) != ' ') {
charsToDelete++;
}
myDocument.deleteString(startOffset, startOffset + charsToDelete);
return;
}
String text = myDocument.getCharsSequence().subSequence(startOffset, endOffset).toString();