Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-09-20 12:36:23 +0000
committerPaul Pazderski2019-09-20 12:36:57 +0000
commit91e2727b9ce67b601ae9f5a455c5b7c83813be6b (patch)
treee79cfd6a8726bc7f43c11a789cac1683054c7399
parentd82a4a4095918a66621d6c589379d3ba9b10a03f (diff)
downloadeclipse.platform.text-91e2727b9ce67b601ae9f5a455c5b7c83813be6b.tar.gz
eclipse.platform.text-91e2727b9ce67b601ae9f5a455c5b7c83813be6b.tar.xz
eclipse.platform.text-91e2727b9ce67b601ae9f5a455c5b7c83813be6b.zip
Bug 549663 - Eclipse Quick Text Search: Scroll in Preview Window
Fix stupid bug which prevent the preview window to center on the match. Change-Id: I90c23ea027b721b217b5d91d15ee0a5ba20e303a Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r--org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java b/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java
index 82f74642d..1bcb3c52b 100644
--- a/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java
+++ b/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java
@@ -972,8 +972,8 @@ public class QuickSearchDialog extends SelectionStatusDialog {
if (document!=null) {
try {
int line = item.getLineNumber()-1; //in document lines are 0 based. In search 1 based.
- int previewTopLine = Math.max(line-(numLines-1)/2, 0); // when this is top line in preview the match will be centered
- int start = document.getLineOffset(Math.max(previewTopLine - context, 0));
+ int contextStartLine = Math.max(line-(numLines-1)/2 - context, 0);
+ int start = document.getLineOffset(contextStartLine);
int end = document.getLength();
try {
IRegion lineInfo = document.getLineInformation(line + numLines/2 + context);
@@ -986,7 +986,7 @@ public class QuickSearchDialog extends SelectionStatusDialog {
StyledString styledString = highlightMatches(document.get(start, end-start));
details.setText(styledString.getString());
details.setStyleRanges(styledString.getStyleRanges());
- details.setTopIndex(previewTopLine);
+ details.setTopIndex(Math.max(line - contextStartLine - numLines/2, 0));
return;
} catch (BadLocationException e) {
}

Back to the top