void () { StringBuilder buffer = new StringBuilder("0123456789"); RangeMarker marker = createMarker(buffer.toString(), 2, 5); WriteAction.run(() -> { synchronizer.startTransaction(getProject(), document, psiFile); synchronizer.replaceString(document, 0, 10, "0"); buffer.replace(0, 10, "0"); for (int i = 1; i < 10; i++) { synchronizer.insertString(document, i, String.valueOf(i)); buffer.insert(i, i); } PsiToDocumentSynchronizer.DocumentChangeTransaction transaction = Objects.requireNonNull(synchronizer.getTransaction(document)); assertSize(1, transaction.getAffectedFragments().keySet()); synchronizer.commitTransaction(document); assertEquals(buffer.toString(), document.getText()); assertValidMarker(marker, 2, 5); }); }