void (final int offset, final int length, final @Nullable String text) { Document document = myEditor.getDocument(); RangeMarker marker = document.createRangeMarker(offset, offset + length); TransactionGuard.submitTransaction(myEditor.getDisposable(), () -> { Project project = myEditor.getProject(); if (!marker.isValid() || !FileDocumentManager.getInstance().requestWriting(document, project)) { marker.dispose(); return; } CommandProcessor.getInstance().executeCommand(project, () -> WriteAction.run(() -> { document.startGuardedBlockChecking(); try { document.replaceString(marker.getStartOffset(), marker.getEndOffset(), StringUtil.notNullize(text)); } catch (ReadOnlyFragmentModificationException e) { EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(document).handle(e); } finally { document.stopGuardedBlockChecking(); marker.dispose(); } }), "", document, UndoConfirmationPolicy.DEFAULT, document); }); }