Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2007-10-29 13:56:28 +0000
committerDarin Wright2007-10-29 13:56:28 +0000
commit0385947ef36aff2a79e6f5c0a1afdcfdfc6b336e (patch)
treec942d1e6d792f173433186404d3b8e1ed93f88bc /org.eclipse.ui.console
parente7f76601cbec77442295c0014de096812cf9709b (diff)
downloadeclipse.platform.debug-0385947ef36aff2a79e6f5c0a1afdcfdfc6b336e.tar.gz
eclipse.platform.debug-0385947ef36aff2a79e6f5c0a1afdcfdfc6b336e.tar.xz
eclipse.platform.debug-0385947ef36aff2a79e6f5c0a1afdcfdfc6b336e.zip
Bug 207743 StringIndexOutOfBoundsException in ConsoleDocumentAdapter
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java47
1 files changed, 25 insertions, 22 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
index 456e834cc..c5b18e629 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
@@ -320,34 +320,37 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4994840
// see bug 84641
int offset = string.length() - 1;
- while (string.charAt(offset) == '\r') {
+ while (offset >= 0 && string.charAt(offset) == '\r') {
offset--;
count++;
}
- if (offset < (string.length() - 1)) {
- string = string.substring(0, offset);
- }
-
- int lastIndex = 0;
- int index = 0;
-
- Matcher matcher = pattern.matcher(string);
-
- while (matcher.find()) {
- index = matcher.start();
+ // if offset == 0, the line was all '\r' and there is no string to search for matches (bug 207743)
+ if (offset > 0) {
+ if (offset < (string.length() - 1)) {
+ string = string.substring(0, offset);
+ }
- if (index == 0)
- count++;
- else if (index!=string.length())
- count++;
+ int lastIndex = 0;
+ int index = 0;
- if (consoleWidth > 0) {
- int lineLen = index - lastIndex + 1;
- if (index == 0) lineLen += lengths[regionCount-1];
- count += lineLen/consoleWidth;
- }
+ Matcher matcher = pattern.matcher(string);
- lastIndex = index;
+ while (matcher.find()) {
+ index = matcher.start();
+
+ if (index == 0)
+ count++;
+ else if (index!=string.length())
+ count++;
+
+ if (consoleWidth > 0) {
+ int lineLen = index - lastIndex + 1;
+ if (index == 0) lineLen += lengths[regionCount-1];
+ count += lineLen/consoleWidth;
+ }
+
+ lastIndex = index;
+ }
}
return count;
}

Back to the top