When the control is inside ScrollViewer and you click it, focus is lost and caret disappears. Some controls have built in ScrollViewer , for example LayoutControl so placing the editor in LayoutControl also leads to the same issue.
Generally placing the syntaxeditor in scrollviewer is risky for the vertical virtualization so at least a height should be set to the control. In R2 2020 SP, an exception will be thrown if Syntax Editor with no height is added in scroll viewer or stack panel or other panel which measures vertically with infinity.
Workaround for this issue:
private void syntaxEditor_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)