Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2018-11-19 15:20:12 +0000
committerangelozerr2018-11-19 15:20:12 +0000
commit0cbe3ef0a78e36bccb3a9f2fd90594e87f4896b5 (patch)
tree1da801a987b4f42a97e1eea462822ead35e50efa
parent222b86399d8e37507e6b00f0c11ef2f8f0bd0c6b (diff)
downloadeclipse.platform.text-0cbe3ef0a78e36bccb3a9f2fd90594e87f4896b5.tar.gz
eclipse.platform.text-0cbe3ef0a78e36bccb3a9f2fd90594e87f4896b5.tar.xz
eclipse.platform.text-0cbe3ef0a78e36bccb3a9f2fd90594e87f4896b5.zip
Bug 540448 - [code mining] How to create code minings at the end of the
line Change-Id: I977f3ca989071faada8e336c51acf1eeec711464 Signed-off-by: angelozerr <angelo.zerr@gmail.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java50
1 files changed, 26 insertions, 24 deletions
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 c2313977a..97975cc29 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
@@ -147,16 +147,14 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
return;
}
if (gc != null) {
+ String s= textWidget.getText(offset, offset);
+ boolean isEndOfLine= ("\r".equals(s) || "\n".equals(s)); //$NON-NLS-1$ //$NON-NLS-2$
+
// Compute the location of the annotation
Rectangle bounds= textWidget.getTextBounds(offset, offset);
- int x= bounds.x;
+ int x= bounds.x + (isEndOfLine ? bounds.width * 2 : 0);
int y= bounds.y;
- // Get size of the character where GlyphMetrics width is added
- String s= textWidget.getText(offset, offset);
- Point charBounds= gc.stringExtent(s);
- int charWidth= charBounds.x;
-
// When line text has line header annotation, there is a space on the top, adjust the y by using char height
y+= bounds.height - textWidget.getLineHeight();
@@ -165,25 +163,29 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
annotation.draw(gc, textWidget, offset, length, color, x, y);
int width= annotation.getWidth();
if (width != 0) {
- // FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
- // START TO REMOVE
- annotation.setRedrawnCharacterWidth(charWidth);
- // END TO REMOVE
+ if (!isEndOfLine) {
+ // Get size of the character where GlyphMetrics width is added
+ Point charBounds= gc.stringExtent(s);
+ int charWidth= charBounds.x;
- // Annotation takes place, add GlyphMetrics width to the style
- StyleRange newStyle= updateStyle(annotation, style);
- if (newStyle != null) {
- textWidget.setStyleRange(newStyle);
- return;
- }
+ // FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
+ // START TO REMOVE
+ annotation.setRedrawnCharacterWidth(charWidth);
+ // END TO REMOVE
+
+ // Annotation takes place, add GlyphMetrics width to the style
+ StyleRange newStyle= updateStyle(annotation, style);
+ if (newStyle != null) {
+ textWidget.setStyleRange(newStyle);
+ return;
+ }
- // FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
- // START TO REMOVE
- // The inline annotation replaces one character by taking a place width
- // GlyphMetrics
- // Here we need to redraw this first character (if it's not a line delimiter) because GlyphMetrics clip this
- // character.
- if (!("\r".equals(s) || "\n".equals(s))) { //$NON-NLS-1$ //$NON-NLS-2$
+ // FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
+ // START TO REMOVE
+ // The inline annotation replaces one character by taking a place width
+ // GlyphMetrics
+ // Here we need to redraw this first character because GlyphMetrics clip this
+ // character.
int charX= x + bounds.width - charWidth;
int charY= y;
if (style != null) {
@@ -220,7 +222,7 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
*/
static StyleRange updateStyle(LineContentAnnotation annotation, StyleRange style) {
int width= annotation.getWidth();
- if (width == 0) {
+ if (width == 0 || annotation.getRedrawnCharacterWidth() == 0) {
return null;
}
int fullWidth= width + annotation.getRedrawnCharacterWidth();

Back to the top