}
private void endRecording(int cursorPosition, int selectionLength) {
IDocument doc = getDocument();
if (doc instanceof IStructuredDocument) {
IStructuredDocument structuredDocument = (IStructuredDocument) doc;
IStructuredTextUndoManager undoManager = structuredDocument.getUndoManager();
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=198617
// undo after paste in document with folds - wrong behavior
IRegion widgetSelection = new Region(cursorPosition, selectionLength);
IRegion documentSelection = widgetRange2ModelRange(widgetSelection);