Bug 579179 - [Multiple carets] Text component gaining focus only draws
first caret

Redraw multiple carets if StyledText gains focus

Change-Id: I7edecb99682b3c68066495602a3176e2ef497760
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/191674
Tested-by: Mickael Istria <mistria@redhat.com>
Reviewed-by: Mickael Istria <mistria@redhat.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index a3fed24..527a8f1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -9239,6 +9239,21 @@
 		this.insideSetEnableCall = false;
 	}
 }
+
+@Override
+public boolean setFocus() {
+	boolean focusGained = super.setFocus();
+	if (focusGained && hasMultipleCarets()) {
+		// Multiple carets need to update their drawing. See bug 579179
+		setCaretLocations();
+	}
+	return focusGained;
+}
+
+private boolean hasMultipleCarets() {
+	return carets != null && carets.length > 1;
+}
+
 /**
  * Sets a new font to render text with.
  * <p>