Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-09-15 16:31:07 +0000
committerPaul Pazderski2019-09-16 20:54:46 +0000
commit8e6fec5714d9cc3c042beb33967abc37f4ad68f6 (patch)
tree4eb903a5021509bfefca31905cc591491b83bab7
parent99343732ef96cc019cb8bac7acddca2c5e3e2cd3 (diff)
downloadeclipse.platform.text-I20190916-1800.tar.gz
eclipse.platform.text-I20190916-1800.tar.xz
eclipse.platform.text-I20190916-1800.zip
Bug 549663 - Eclipse Quick Text Search: Scroll in Preview WindowI20190916-1800
Change-Id: Ie2f359af87d287cc8bb402c91f8b0394041889da Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r--org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java10
1 files changed, 6 insertions, 4 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 7db1b8c40a6..b1c717cd1f3 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
@@ -938,7 +938,7 @@ public class QuickSearchDialog extends SelectionStatusDialog {
}
private void createDetailsArea(Composite parent) {
- details = new StyledText(parent, SWT.MULTI+SWT.READ_ONLY+SWT.BORDER+SWT.H_SCROLL);
+ details = new StyledText(parent, SWT.MULTI+SWT.READ_ONLY+SWT.BORDER+SWT.H_SCROLL+SWT.V_SCROLL);
details.setFont(JFaceResources.getFont(TEXT_FONT));
list.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -966,6 +966,7 @@ public class QuickSearchDialog extends SelectionStatusDialog {
details.setText(""); //$NON-NLS-1$
} else {
//Not empty selection
+ final int context = 100; // number of lines before and after match to include in preview
int numLines = computeLines();
if (numLines > 0) {
LineItem item = (LineItem) sel.getFirstElement();
@@ -973,10 +974,11 @@ 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 start = document.getLineOffset(Math.max(line-(numLines-1)/2, 0));
+ 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 end = document.getLength();
try {
- IRegion lineInfo = document.getLineInformation(line + numLines/2);
+ IRegion lineInfo = document.getLineInformation(line + numLines/2 + context);
end = lineInfo.getOffset() + lineInfo.getLength();
} catch (BadLocationException e) {
//Presumably line number is past the end of document.
@@ -986,7 +988,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);
return;
} catch (BadLocationException e) {
}

Back to the top