fixed commenter (PY-1950)
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 23 Sep 2010 14:14:08 +0000 (18:14 +0400)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 23 Sep 2010 16:39:48 +0000 (20:39 +0400)
platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java

index d19617643c2198fb81ac25a0b3eba85719d6a315..ed3c2b59d9ac96c4b49d5ae9b48baafaee82d44a 100644 (file)
@@ -475,14 +475,20 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
       if (commenter instanceof CommenterWithLineSuffix) {
         CommenterWithLineSuffix commenterWithLineSuffix = (CommenterWithLineSuffix)commenter;
         String suffix = commenterWithLineSuffix.getLineCommentSuffix();
+
+
         int theEnd = endOffset > 0 ? endOffset : myDocument.getLineEndOffset(line);
         while (theEnd > startOffset && Character.isWhitespace(chars.charAt(theEnd - 1))) {
           theEnd--;
         }
 
-        if (CharArrayUtil.regionMatches(chars, theEnd - suffix.length(), suffix)) {
-          myDocument.deleteString(theEnd - suffix.length(), theEnd);
+
+        String lineText = myDocument.getText(new TextRange(startOffset, theEnd));
+        if (lineText.indexOf(suffix) != -1) {
+          int start = startOffset + lineText.indexOf(suffix);
+          myDocument.deleteString(start, start + suffix.length());
         }
+
       }
 
       boolean skipNewLine = false;
@@ -633,4 +639,4 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
       }
     }
   }
-}
+}
\ No newline at end of file