void () { typeInText("initial"); final StartMarkAction[] compound = new StartMarkAction[1]; CommandProcessor.getInstance().executeCommand(getProject(), () -> { try { final StartMarkAction markAction = StartMarkAction.start(getFirstEditor(), getProject(), "compound"); typeInText("to undo1"); finish(markAction); compound[0] = StartMarkAction.start(getFirstEditor(), getProject(), "compound"); } catch (StartMarkAction.AlreadyStartedException e) { e.printStackTrace(); } }, "start", null, getFirstEditor().getDocument()); typeInText("to undo2"); finish(compound[0]); undoFirstEditor(); checkEditorText("initial"); }