Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2015-04-15 06:47:33 -0400
committerSarika Sinha2015-04-15 06:52:00 -0400
commita5cd12c947a8b95276313f78e5eef3ebe59d7d5a (patch)
treef332d050245629f9deb0bcadb6411fcaf2e747b8 /org.eclipse.ui.console
parent213c098cb78bf40881628dcdaf345b3898070ba8 (diff)
downloadeclipse.platform.debug-a5cd12c947a8b95276313f78e5eef3ebe59d7d5a.tar.gz
eclipse.platform.debug-a5cd12c947a8b95276313f78e5eef3ebe59d7d5a.tar.xz
eclipse.platform.debug-a5cd12c947a8b95276313f78e5eef3ebe59d7d5a.zip
Bug 464602 - [Console] Console auto scrolls only after 2nd input
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java
index 2ede958dc..65a0e8899 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.widgets.Composite;
@@ -100,6 +101,7 @@ public class IOConsoleViewer extends TextConsoleViewer {
} else {
try {
doc.replace(length, 0, eventString);
+ updateWidgetCaretLocation(length);
} catch (BadLocationException e1) {
}
e.doit = false;
@@ -110,6 +112,29 @@ public class IOConsoleViewer extends TextConsoleViewer {
}
}
+ /*
+ * Update the Text widget location to new location
+ */
+ private void updateWidgetCaretLocation(int documentCaret) {
+ int widgetCaret = modelOffset2WidgetOffset(documentCaret);
+ if (widgetCaret == -1) {
+ // try to move it to the closest spot
+ IRegion region = getModelCoverage();
+ if (region != null) {
+ if (documentCaret <= region.getOffset()) {
+ widgetCaret = 0;
+ } else if (documentCaret >= region.getOffset() + region.getLength()) {
+ widgetCaret = getVisibleRegion().getLength();
+ }
+ }
+ }
+ if (widgetCaret != -1) {
+ // there is a valid widget caret
+ getTextWidget().setCaretOffset(widgetCaret);
+ getTextWidget().showSelection();
+ }
+ }
+
/**
* makes the associated text widget uneditable.
*/

Back to the top