дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +02:00
Compare Directories opens as a restorable editor tab instead of a modal dialog. The table shows name, size and date for each side with a status marker between them, colours rows by status, groups files under their folder (a folder present on both sides heads its group and can be copied whole; a one-sided folder is one row), and previews the selected file's diff below; Enter or double-click opens it in its own tab. Toolbar toggles filter by status. The backend comparison now returns each side's file size and modification time. Part of #3925
28 рядки
1.2 KiB
TypeScript
28 рядки
1.2 KiB
TypeScript
/** Compare Directories tab input; kept apart from `DirectoryCompare` so opening one does not load it. */
|
|
import { editorService, type EditorInput } from "@/workbench/contributions";
|
|
import { baseName } from "./model";
|
|
|
|
export const DIRECTORY_COMPARE_KIND = "directoryCompare";
|
|
|
|
export interface DirectoryCompareData {
|
|
left: string;
|
|
right: string;
|
|
}
|
|
|
|
export function directoryCompareInput(left: string, right: string): EditorInput {
|
|
return { kind: DIRECTORY_COMPARE_KIND, key: `directoryCompare:${left}\n${right}`, data: { left, right } };
|
|
}
|
|
|
|
/** "a ↔ b", or with the parent folders when both folders have the same name (`x/config ↔ y/config`). */
|
|
export function directoryCompareTitle({ left, right }: DirectoryCompareData): string {
|
|
const [l, r] = [left, right].map((p) => p.replace(/[\\/]+$/, "")) as [string, string];
|
|
const same = baseName(l) === baseName(r);
|
|
const name = (path: string) => (same ? path.split(/[\\/]/).slice(-2).join("/") : baseName(path));
|
|
return `${name(l)} ↔ ${name(r)}`;
|
|
}
|
|
|
|
export function showDirectoryComparison(left: string, right: string) {
|
|
if (left === right) return;
|
|
void editorService().openInput(directoryCompareInput(left, right), { focus: true });
|
|
}
|