From f7e19d1185f1d8c4ddc7fc7ace6292060fabf45e Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Tue, 16 Feb 2016 14:44:21 +0300 Subject: [PATCH] FIXED WEB-20285 IOOBE on creating Line Comment in the end of JS/TS file --- .../codeInsight/generation/CommentByLineCommentHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java index 2d1759ac7340..b1653d81eb3c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java @@ -640,7 +640,9 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand } } else { - if (block.addSpace && document.getCharsSequence().charAt(shiftedStartOffset) != '\n') { + if (block.addSpace && + shiftedStartOffset < document.getTextLength() && + document.getCharsSequence().charAt(shiftedStartOffset) != '\n') { prefix += ' '; } document.insertString(offset, prefix);