Bug 529076 - [CodeMining] Infinite draw when code mining is hidden on
top

Change-Id: I1a45c53446bc05334e03b79f447d1c214c7b6f89
Signed-off-by: angelozerr <angelo.zerr@gmail.com>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java
index 1580511..8a9647f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java
@@ -18,6 +18,8 @@
 import org.eclipse.swt.graphics.GlyphMetrics;
 import org.eclipse.swt.graphics.Rectangle;
 
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension5;
 import org.eclipse.jface.text.JFaceTextUtil;
 import org.eclipse.jface.text.source.Annotation;
 import org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy;
@@ -86,10 +88,10 @@
 		}
 		int previousLineIndex= lineIndex - 1;
 		// check the previous line index where annotation must be drawn in line spacing is not hidden
-		int firstLineIndex= JFaceTextUtil.getPartialTopIndex(annotation.getViewer());
-		if (previousLineIndex < firstLineIndex) {
-			// the previous line index where annotation must be drawn in line spacing is hidden, don't draw it.
-			return;
+		ITextViewer viewer= annotation.getViewer();
+		int firstLineIndex= JFaceTextUtil.getPartialTopIndex(viewer);
+		if (viewer instanceof ITextViewerExtension5) {
+			firstLineIndex= ((ITextViewerExtension5) viewer).modelLine2WidgetLine(firstLineIndex);
 		}
 		if (gc != null) {
 			// Compute the location of the annotation