Skip to content

Commit 3b02ed7

Browse files
fix NPE
1 parent 8b2948b commit 3b02ed7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/ZeroWidthCharactersLineContentCodeMining.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
class ZeroWidthCharactersLineContentCodeMining extends LineContentCodeMining {
3434

3535
private static final String ZW_CHARACTERS_MINING = "ZWSP"; //$NON-NLS-1$
36-
private Color fgColor;
3736

3837
public ZeroWidthCharactersLineContentCodeMining(int offset, ICodeMiningProvider provider) {
3938
super(new Position(offset, 1), true, provider);
40-
fgColor = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
4139
}
4240

4341
@Override
@@ -52,9 +50,14 @@ public String getLabel() {
5250

5351
@Override
5452
public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) {
55-
gc.setForeground(fgColor);
56-
Point point = super.draw(gc, textWidget, fgColor, x, y);
53+
gc.setForeground(getColor(color));
54+
Point point = super.draw(gc, textWidget, color, x, y);
5755
gc.setForeground(color);
5856
return point;
5957
}
58+
59+
private Color getColor(Color predefinedColor) {
60+
return Display.getCurrent() != null ? Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND)
61+
: predefinedColor;
62+
}
6063
}

0 commit comments

Comments
 (0)