From d006433f6bb753a28bef356062834a0cfc0e587b Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 22 Nov 2013 12:23:49 +0100 Subject: [PATCH] EA-50192 (IOOBE: CharArrayCharSequence.) --- .../siyeh/ipp/unicode/UnicodeUnescapeIntention.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/unicode/UnicodeUnescapeIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/unicode/UnicodeUnescapeIntention.java index e885764e6ecd..0137f987a32e 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/unicode/UnicodeUnescapeIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/unicode/UnicodeUnescapeIntention.java @@ -140,14 +140,19 @@ public class UnicodeUnescapeIntention extends Intention { return false; } final SelectionModel selectionModel = editor.getSelectionModel(); + final Document document = editor.getDocument(); if (selectionModel.hasSelection()) { - final String text = selectionModel.getSelectedText(); - // an editor can have a selection, but still null for selected text (because of threading?). - return text != null && indexOfUnicodeEscape(text, 1) >= 0; + final int start = selectionModel.getSelectionStart(); + final int end = selectionModel.getSelectionEnd(); + if (start < 0 || end < 0 || start > end) { + // shouldn't happen but http://ea.jetbrains.com/browser/ea_problems/50192 + return false; + } + final String text = document.getCharsSequence().subSequence(start, end).toString(); + return indexOfUnicodeEscape(text, 1) >= 0; } else { final CaretModel caretModel = editor.getCaretModel(); - final Document document = editor.getDocument(); final int lineNumber = document.getLineNumber(caretModel.getOffset()); final String line = document.getText(new TextRange(document.getLineStartOffset(lineNumber), document.getLineEndOffset(lineNumber))); final int column = caretModel.getLogicalPosition().column;