Z ZPI 文档 v0.3.8
介绍页

源码

packages/desktop/src/renderer/workspace-file-tree/refresh-directories.ts

typescript33 行查看原文
// Adapted from ZCode workspace-file-tree; see licenses/third-party-notices.txt.
import { isWorkspaceFilePathInside } from "./model.ts";

export function getWorkspaceFileTreeRefreshDirectoryPaths({
  workspacePath,
  expandedPaths,
  loadedDirectoryPaths,
}: {
  workspacePath: string;
  expandedPaths: ReadonlySet<string>;
  loadedDirectoryPaths: ReadonlySet<string>;
}): string[] {
  const refreshPaths: string[] = [];
  const seenPaths = new Set<string>();
  const addRefreshPath = (path: string) => {
    if (!isWorkspaceFilePathInside(workspacePath, path) || seenPaths.has(path)) {
      return;
    }
    seenPaths.add(path);
    refreshPaths.push(path);
  };

  addRefreshPath(workspacePath);
  for (const path of loadedDirectoryPaths) {
    addRefreshPath(path);
  }
  for (const path of expandedPaths) {
    addRefreshPath(path);
  }

  return refreshPaths;
}