Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

660 B
Raw Blame
import { useProject } from "@/platform/project";
import type { DiffData } from "./diffInput";

/** Project-relative path for labels. */
export function displayPath(path: string, root = useProject.getState().project?.root ?? null): string {
  return root && path.startsWith(root + "/") ? path.slice(root.length + 1) : path;
}

/** Diff of two files on disk; both sides are live, editable documents. */
export function compareFilesData(leftPath: string, rightPath: string): DiffData {
  return {
    path: rightPath,
    left: { type: "file", path: leftPath, label: displayPath(leftPath) },
    right: { type: "worktree", label: displayPath(rightPath) },
  };
}