void () { final VirtualFile file1 = createChildData(myRoot, "file1.txt"); final VirtualFile file2 = createChildData(myRoot, "file2.txt"); final Document document1 = FileDocumentManager.getInstance().getDocument(file1); final Document document2 = FileDocumentManager.getInstance().getDocument(file2); Mock.MyFileEditor fileEditor = new Mock.MyFileEditor(document1, document2) { @Override public @NotNull VirtualFile getFile() { return file1; } }; UndoManager undoManager = UndoManager.getInstance(myProject); CommandProcessor.getInstance() .executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> document2.replaceString(0, 0, "text2")), "test_command", null, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION); assertTrue(undoManager.isUndoAvailable(fileEditor)); undoManager.undo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("", document1.getText()); assertEquals("", document2.getText()); undoManager.redo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("", document1.getText()); assertEquals("text2", document2.getText()); changeText(document1, ""); changeText(document2, ""); changeText(document1, "text1"); changeText(document2, "text2"); assertTrue(undoManager.isUndoAvailable(fileEditor)); undoManager.undo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("text1", document1.getText()); assertEquals("", document2.getText()); undoManager.undo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("", document1.getText()); assertEquals("", document2.getText()); undoManager.redo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("text1", document1.getText()); assertEquals("", document2.getText()); undoManager.redo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("text1", document1.getText()); assertEquals("text2", document2.getText()); //check documents changes backward changeText(document1, ""); changeText(document2, ""); changeText(document2, "text2"); changeText(document1, "text1"); assertTrue(undoManager.isUndoAvailable(fileEditor)); undoManager.undo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("text2", document2.getText()); assertEquals("", document1.getText()); undoManager.undo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("", document1.getText()); assertEquals("", document2.getText()); undoManager.redo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("", document1.getText()); assertEquals("text2", document2.getText()); undoManager.redo(fileEditor); assertFalse(myConfirmationWasRequested); assertEquals("text1", document1.getText()); assertEquals("text2", document2.getText()); }