void () { final String hugeText = StringUtil.repeat(" asdlkjfh lkjsadf kjhasdklfjhalsdkjfh laskdjhf lkajdh\n", 1000); WriteCommandAction.runWriteCommandAction(null, () -> { getFirstEditor().getDocument().insertString(0, hugeText); getFirstEditor().getSelectionModel().setSelection(0, getFirstEditor().getDocument().getTextLength()); }); CommandProcessor.getInstance().executeCommand( getProject(), () -> new IndentSelectionAction().getHandler() .execute(getFirstEditor(), null, DataManager.getInstance().getDataContext(getFirstEditor().getContentComponent())), "", this); final int[] bulkStarted = new int[1]; final int[] bulkFinished = new int[1]; EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentListener() { @Override public void bulkUpdateStarting(@NotNull Document document) { bulkStarted[0]++; } @Override public void bulkUpdateFinished(@NotNull Document document) { bulkFinished[0]++; } }, getTestRootDisposable()); undoFirstEditor(); assertEquals(1, bulkStarted[0]); assertEquals(1, bulkFinished[0]); }