fixed django template commenter again (PY-1949)
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 14 Oct 2010 15:26:23 +0000 (19:26 +0400)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 14 Oct 2010 18:43:53 +0000 (22:43 +0400)
platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java

index ed3c2b59d9ac96c4b49d5ae9b48baafaee82d44a..c3c8731430c301152f6f62f73d1692fd9ff52099 100644 (file)
@@ -488,7 +488,6 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
           int start = startOffset + lineText.indexOf(suffix);
           myDocument.deleteString(start, start + suffix.length());
         }
-
       }
 
       boolean skipNewLine = false;
@@ -554,9 +553,10 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
         endOffset = CharArrayUtil.shiftBackward(myDocument.getCharsSequence(), endOffset, " \t");
         int shiftedStartOffset = CharArrayUtil.shiftForward(myDocument.getCharsSequence(), offset, " \t");
         String lineSuffix = ((CommenterWithLineSuffix)commenter).getLineCommentSuffix();
-        if (!CharArrayUtil.regionMatches(myDocument.getCharsSequence(), endOffset - lineSuffix.length(), lineSuffix) &&
-            !CharArrayUtil.regionMatches(myDocument.getCharsSequence(), shiftedStartOffset, prefix)) {
-          myDocument.insertString(endOffset, lineSuffix);
+        if (!CharArrayUtil.regionMatches(myDocument.getCharsSequence(), shiftedStartOffset, prefix)) {
+          if (!CharArrayUtil.regionMatches(myDocument.getCharsSequence(), endOffset - lineSuffix.length(), lineSuffix)) {
+            myDocument.insertString(endOffset, lineSuffix);
+          }
           myDocument.insertString(offset, prefix);
         }
       }