void () { final PsiFile file = myElement.getContainingFile(); if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> { try { UnwrapDescriptor d = getUnwrapDescription(file); if (d.shouldTryToRestoreCaretPosition()) saveCaretPosition(file); int scrollOffset = myEditor.getScrollingModel().getVerticalScrollOffset(); List<PsiElement> extractedElements = myUnwrapper.unwrap(myEditor, myElement); if (d.shouldTryToRestoreCaretPosition()) restoreCaretPosition(file); myEditor.getScrollingModel().scrollVertically(scrollOffset); highlightExtractedElements(extractedElements); } catch (IncorrectOperationException ex) { throw new RuntimeException(ex); } }), null, myEditor.getDocument()); }