Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Melcher2015-12-24 12:32:45 -0500
committerTobias Melcher2018-01-15 13:33:10 -0500
commitd678fc595842e7b95d60b3134849ebba4d1f26f6 (patch)
treebe3bb89d215085d15b4f307257623ac7e75a571b
parent7de860acac3eaf2320feef3ef5dda10b46a4b574 (diff)
downloadeclipse.platform.debug-d678fc595842e7b95d60b3134849ebba4d1f26f6.tar.gz
eclipse.platform.debug-d678fc595842e7b95d60b3134849ebba4d1f26f6.tar.xz
eclipse.platform.debug-d678fc595842e7b95d60b3134849ebba4d1f26f6.zip
vertical scroll index is now kept for long strings over multiple lines Change-Id: Id5200c4e933de1aa9d3c1178a0908a52019b3de6 Signed-off-by: Tobias Melcher <tobias.melcher@sap.com>
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java57
1 files changed, 55 insertions, 2 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java
index 9cd79e5af..0b840932f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java
@@ -305,11 +305,57 @@ public class DefaultDetailPane extends AbstractDetailPane implements IDetailPane
if (max > 0 && insert.length() > max) {
insert = insert.substring(0, max) + "..."; //$NON-NLS-1$
}
+ int topIndex = -1;
+ StyledText styledText = fSourceViewer.getTextWidget();
+ Point selection = null;
+ // keep scrolling state in details pane in case
+ // of longer string over multiple lines
+ if (containsLineDelimiter(insert)) {
+ int ti = styledText.getTopIndex();
+ if (ti == 0) {
+ int caretOffset = styledText.getCaretOffset();
+ String topStr = styledText.getText().substring(0, caretOffset);
+ if (insert.length() > caretOffset) {
+ String newTopStr = insert.substring(0, caretOffset);
+ // only when string from start to
+ // caretOffset has not changed
+ if (topStr.equals(newTopStr)) {
+ topIndex = ti;
+ selection = styledText.getSelection();
+ }
+ }
+ } else if (ti > 0) {
+ int topOffset = styledText.getOffsetAtLine(ti);
+ String topStr = styledText.getText().substring(0, topOffset);
+ if (insert.length() > topOffset) {
+ String newTopStr = insert.substring(0, topOffset);
+ // only when string from start to
+ // topIndex has not changed
+ if (topStr.equals(newTopStr)) {
+ topIndex = ti;
+ selection = styledText.getSelection();
+ }
+ }
+ }
+ }
+ IDocument detailDoc = getDetailDocument();
if (fFirst) {
- getDetailDocument().set(insert);
+ if (insert.equals(detailDoc.get())) {
+ topIndex = -1; // source not modified,
+ // no need to set the
+ // document
+ } else {
+ detailDoc.set(insert);
+ }
fFirst = false;
} else {
- getDetailDocument().replace(length, 0,insert);
+ detailDoc.replace(length, 0, insert);
+ }
+ if (topIndex > -1) {
+ styledText.setTopIndex(topIndex);
+ if (selection != null) {
+ styledText.setSelection(selection);
+ }
}
} catch (BadLocationException e) {
DebugUIPlugin.log(e);
@@ -317,6 +363,13 @@ public class DefaultDetailPane extends AbstractDetailPane implements IDetailPane
}
return Status.OK_STATUS;
}
+
+ private boolean containsLineDelimiter(String str) {
+ if (str.contains("\n") || str.contains("\r")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return true;
+ }
+ return false;
+ }
};
append.setSystem(true);
append.schedule();

Back to the top