Skip to content

Commit 4706305

Browse files
mx990mickaelistria
authored andcommitted
Code Mining: Redraw of end-of-line annotation is skipped #1070
The redraw of end-of-line annotations was not handled previously, since the graphics context is null in that case. This change handles such redraws by requesting a redraw of the range from the text widget. Fixes #1070 Signed-off-by: Martin Jobst <[email protected]>
1 parent 301be7a commit 4706305

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,24 @@ private static void draw(LineContentAnnotation annotation, GC gc, StyledText tex
211211
}
212212

213213
private static void drawAfterLine(LineContentAnnotation annotation, GC gc, StyledText textWidget, int widgetOffset, int length, Color color) {
214-
if (gc == null) {
214+
if (isDeleted(annotation)) {
215215
return;
216216
}
217-
if (textWidget.getCharCount() == 0) {
218-
annotation.draw(gc, textWidget, widgetOffset, length, color, 0, 0);
217+
if (gc != null) {
218+
if (textWidget.getCharCount() == 0) {
219+
annotation.draw(gc, textWidget, widgetOffset, length, color, 0, 0);
220+
} else {
221+
int line= textWidget.getLineAtOffset(widgetOffset);
222+
int lineEndOffset= (line == textWidget.getLineCount() - 1) ? //
223+
textWidget.getCharCount() - 1 : //
224+
textWidget.getOffsetAtLine(line + 1) - 1;
225+
Rectangle bounds= textWidget.getTextBounds(lineEndOffset, lineEndOffset);
226+
int lineEndX= bounds.x + bounds.width + gc.stringExtent(" ").x; //$NON-NLS-1$
227+
annotation.setLocation(lineEndX, textWidget.getLinePixel(line) + textWidget.getLineVerticalIndent(line));
228+
annotation.draw(gc, textWidget, widgetOffset, length, color, lineEndX, textWidget.getLinePixel(line) + textWidget.getLineVerticalIndent(line));
229+
}
219230
} else {
220-
int line= textWidget.getLineAtOffset(widgetOffset);
221-
int lineEndOffset= (line == textWidget.getLineCount() - 1) ? //
222-
textWidget.getCharCount() - 1 : //
223-
textWidget.getOffsetAtLine(line + 1) - 1;
224-
Rectangle bounds= textWidget.getTextBounds(lineEndOffset, lineEndOffset);
225-
int lineEndX= bounds.x + bounds.width + gc.stringExtent(" ").x; //$NON-NLS-1$
226-
annotation.setLocation(lineEndX, textWidget.getLinePixel(line) + textWidget.getLineVerticalIndent(line));
227-
annotation.draw(gc, textWidget, widgetOffset, length, color, lineEndX, textWidget.getLinePixel(line) + textWidget.getLineVerticalIndent(line));
231+
textWidget.redrawRange(widgetOffset, length, true);
228232
}
229233
}
230234

0 commit comments

Comments
 (0)