Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions apps/web/src/components/diffs/useReviewFilePatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import {
import { getRenderablePatch, resolveFileDiffPath, type RenderablePatch } from "~/lib/diffRendering";
import { reviewEnvironment } from "~/state/review";

const filePathCollator = new Intl.Collator(undefined, {
numeric: true,
sensitivity: "base",
});

export function useReviewFilePatches({
environmentId,
cwd,
Expand Down Expand Up @@ -49,10 +54,7 @@ export function useReviewFilePatches({
[requested, scope],
);
const files = useMemo(
() =>
source?.files?.toSorted((a, b) =>
a.path.localeCompare(b.path, undefined, { numeric: true, sensitivity: "base" }),
) ?? [],
() => source?.files?.toSorted((a, b) => filePathCollator.compare(a.path, b.path)) ?? [],
[source?.files],
);
const queries = useMemo(
Expand Down Expand Up @@ -191,10 +193,7 @@ export function useReviewFilePatches({
};
})
: (preview?.kind === "files" ? preview.files : []).toSorted((a, b) =>
resolveFileDiffPath(a).localeCompare(resolveFileDiffPath(b), undefined, {
numeric: true,
sensitivity: "base",
}),
filePathCollator.compare(resolveFileDiffPath(a), resolveFileDiffPath(b)),
),
[source, files, patches, scope, preview],
);
Expand Down
Loading