diff options
author | Michael Keppler | 2019-08-15 13:29:31 +0000 |
---|---|---|
committer | Karsten Thoms | 2019-09-16 12:22:24 +0000 |
commit | 0aaf26bd4d6fca6e5f422776da29d4bd9b37aa42 (patch) | |
tree | 427efb4fb6f5729b6af5f0e4ab0f09c7725c13c8 | |
parent | b706c681d2e1dedf9cff05eb1a366db762abc8be (diff) | |
download | eclipse.platform.text-0aaf26bd4d6fca6e5f422776da29d4bd9b37aa42.tar.gz eclipse.platform.text-0aaf26bd4d6fca6e5f422776da29d4bd9b37aa42.tar.xz eclipse.platform.text-0aaf26bd4d6fca6e5f422776da29d4bd9b37aa42.zip |
[Quicksearch] Simplify line number calculation
It's not necessary to deal with font metrics to get the number of lines
being displayed in the preview area.
Change-Id: Id450be2e2f2596c6a2f96683b772e85fed5d4890
Signed-off-by: Michael Keppler <michael.keppler@gmx.de>
-rw-r--r-- | org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java | 15 |
1 files changed, 4 insertions, 11 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 eec298e5286..7db1b8c40a6 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 @@ -999,20 +999,13 @@ public class QuickSearchDialog extends SelectionStatusDialog { } /** - * Computes how much lines of text can be displayed in the details section based on - * its current height and font metrics. + * Computes how many lines of text can be displayed in the details section. */ private int computeLines() { if (details!=null && !details.isDisposed()) { - GC gc = new GC(details); - try { - FontMetrics fm = gc.getFontMetrics(); - int itemH = fm.getHeight(); - int areaH = details.getClientArea().height; - return (areaH+itemH-1) / itemH; - } finally { - gc.dispose(); - } + int lineHeight = details.getLineHeight(); + int areaHeight = details.getClientArea().height; + return (areaHeight + lineHeight - 1) / lineHeight; } return 0; } |