void () { final Document document = getFirstEditor().getDocument(); ApplicationManager.getApplication().runWriteAction(() -> document.setText("test")); moveCaret(4, RIGHT, false); WriteCommandAction.runWriteCommandAction(getProject(), () -> { moveCaret(2, LEFT, false); checkEditorState("test", 2, 0, 0); typeInText("test"); }); checkEditorState("tetestst", 6, 0, 0); undoFirstEditor(); checkEditorState("test", 4, 0, 0); assertUndoInFirstEditorNotAvailable(); }