if (fEditor instanceof ITextEditor) {
// update the selection if text selection changed
if (selectionPosition != null) {
ITextSelection selection = null;
if (updateStartOffset) {
selection = new TextSelection(document, selectionPosition.getOffset() - OPEN_COMMENT.length(), selectionPosition.getLength() + OPEN_COMMENT.length());
}
else {
selection = new TextSelection(document, selectionPosition.getOffset(), selectionPosition.getLength());
}
ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider();
if (provider != null) {
provider.setSelection(selection);
}