Skip to content

Commit f2e78a8

Browse files
committed
Fix code mining sometimes not rendering
Because of confusion between document and widget offset in some comparison. Fixes eclipse-platform#1170
1 parent fe7afe8 commit f2e78a8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void draw(Annotation annotation, GC gc, StyledText textWidget, int widget
7373
}
7474
InlinedAnnotationSupport support = InlinedAnnotationSupport.getSupport(textWidget);
7575
inlinedAnnotation.setSupport(support);
76-
if (support.isInVisibleLines(widgetOffset) && inlinedAnnotation.isFirstVisibleOffset(widgetOffset, viewer)) {
76+
if (support.isInVisibleLines(inlinedAnnotation.getPosition().offset) && inlinedAnnotation.isFirstVisibleOffset(widgetOffset, viewer)) {
7777
GCConfig initialGCConfig = GCConfig.fromGC(gc);
7878
GCConfig annotationGCConfig = new GCConfig(color, textWidget.getBackground(), getAnnotationFont(textWidget));
7979
annotationGCConfig.applyTo(gc);

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,12 @@ private int getExclusiveBottomIndexEndOffset() {
219219
/**
220220
* Return whether the given offset is in visible lines.
221221
*
222-
* @param offset the offset
222+
* @param documentOffset the document relative offset
223223
* @return <code>true</code> if the given offset is in visible lines and <code>false</code>
224224
* otherwise.
225225
*/
226226
@SuppressWarnings("boxing")
227-
boolean isInVisibleLines(int offset) {
227+
boolean isInVisibleLines(int documentOffset) {
228228
if (endOffset == null) {
229229
Display display= fViewer.getTextWidget().getDisplay();
230230
if (display.getThread() == Thread.currentThread()) {
@@ -233,7 +233,7 @@ boolean isInVisibleLines(int offset) {
233233
display.syncExec(() -> endOffset= getExclusiveBottomIndexEndOffset());
234234
}
235235
}
236-
return offset >= startOffset && offset <= endOffset;
236+
return documentOffset >= startOffset && documentOffset <= endOffset;
237237
}
238238

239239
/**
@@ -548,16 +548,16 @@ private AbstractInlinedAnnotation getInlinedAnnotationAtPoint(int x, int y) {
548548
/**
549549
* Return whether the given offset is in visible lines.
550550
*
551-
* @param offset the offset
551+
* @param documentOffset the document offset
552552
* @return <code>true</code> if the given offset is in visible lines and <code>false</code>
553553
* otherwise.
554554
*/
555-
boolean isInVisibleLines(int offset) {
555+
boolean isInVisibleLines(int documentOffset) {
556556
if (visibleLines == null) {
557557
// case of support has been uninstalled and mining must be drawn.
558558
return false;
559559
}
560-
return visibleLines.isInVisibleLines(offset);
560+
return visibleLines.isInVisibleLines(documentOffset);
561561
}
562562

563563

0 commit comments

Comments
 (0)