private static boolean canUndo(@NotNull VirtualFile virtualFile, @NotNull Project project) {
    ThreadingAssertions.assertEventDispatchThread();
    List<FileEditor> editors = FileEditorManager.getInstance(project).getEditorList(virtualFile);
    if (editors.isEmpty()) {
      return false;
    }

    UndoManager undoManager = UndoManager.getInstance(project);
    for (FileEditor editor : editors) {
      if (undoManager.isUndoAvailable(editor)) {
        return true;
      }
    }
    return false;
  }
private static boolean canUndo(@NotNull VirtualFile virtualFile, @NotNull Project project)