FIXED WEB-20285 IOOBE on creating Line Comment in the end of JS/TS file

This commit is contained in:
Rustam Vishnyakov
2016-02-16 14:45:04 +03:00
parent 216ac5b802
commit f7e19d1185
@@ -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);