Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2007-10-29 14:30:27 +0000
committerDarin Wright2007-10-29 14:30:27 +0000
commit8744b50210405bd5cb6bf28e1e7e06c20e94749d (patch)
treec0294c4d8f59c43b2fb46db0c79c1cc469f2d31b
parent6ec77f02669b8de8ca9b499c402940f8f8e1b91b (diff)
downloadeclipse.platform.debug-8744b50210405bd5cb6bf28e1e7e06c20e94749d.tar.gz
eclipse.platform.debug-8744b50210405bd5cb6bf28e1e7e06c20e94749d.tar.xz
eclipse.platform.debug-8744b50210405bd5cb6bf28e1e7e06c20e94749d.zip
Bug 207743 - StringIndexOutOfBoundsException in ConsoleDocumentAdapter
-rw-r--r--org.eclipse.ui.console/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java47
2 files changed, 26 insertions, 23 deletions
diff --git a/org.eclipse.ui.console/META-INF/MANIFEST.MF b/org.eclipse.ui.console/META-INF/MANIFEST.MF
index efb2d9bda..2e5a3726f 100644
--- a/org.eclipse.ui.console/META-INF/MANIFEST.MF
+++ b/org.eclipse.ui.console/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.console; singleton:=true
-Bundle-Version: 3.2.1.qualifier
+Bundle-Version: 3.2.2.qualifier
Bundle-Activator: org.eclipse.ui.console.ConsolePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
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