Document doc = editor.getDocument();
final SelectionModel selectionModel = editor.getSelectionModel();
if (selectionModel.hasBlockSelection()) {
RangeMarker guard = selectionModel.getBlockSelectionGuard();
if (guard != null) {
DocumentEvent evt = new MockDocumentEvent(doc, editor.getCaretModel().getOffset());
ReadOnlyFragmentModificationException e = new ReadOnlyFragmentModificationException(evt, guard);
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler().handle(e);
}
else {
final LogicalPosition start = selectionModel.getBlockStart();