void () { Document document = getDocument(findFile(createFile())); WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, " ")); ProgressManager.getInstance().run(new Task.Modal(myProject, "", true) { @Override public void run(@NotNull ProgressIndicator indicator) { assertFalse(getPsiDocumentManager().isCommitted(document)); getPsiDocumentManager().commitAndRunReadAction(() -> assertTrue(getPsiDocumentManager().isCommitted(document))); } }); }