Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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