fix SIOOBE

This commit is contained in:
Bas Leijdekkers
2013-09-16 10:40:22 +02:00
parent dcfd5ea040
commit af9ffb8993
3 changed files with 10 additions and 1 deletions
@@ -69,8 +69,12 @@ public class UnicodeUnescapeIntention extends Intention {
final Document document = editor.getDocument();
final int offset = caretModel.getOffset();
final String text = document.getText(new TextRange(Math.max(offset - 6, 0), Math.min(offset + 6, document.getTextLength())));
final int max = Math.min(7, text.length());
final int textLength = text.length();
final int max = Math.min(7, textLength);
for (int i = 0; i < max; i++) {
if (i + 5 >= textLength) {
//return false;
}
if (text.charAt(i) == '\\' &&
text.charAt(i + 1) == 'u' &&
StringUtil.isHexDigit(text.charAt(i + 2)) &&
@@ -0,0 +1 @@
// \u<caret>0
@@ -3,9 +3,13 @@ package com.siyeh.ipp.unicode;
import com.siyeh.IntentionPowerPackBundle;
import com.siyeh.ipp.IPPTestCase;
/**
* @see com.siyeh.ipp.unicode.UnicodeUnescapeIntention
*/
public class UnicodeUnescapeIntentionTest extends IPPTestCase {
public void testSimple() { doTest(); }
public void testNoException() { assertIntentionNotAvailable(); }
@Override
protected String getRelativePath() {