mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-26 11:12:53 +00:00
fix(app): align the scrolling diff order with the Changes tree (#3913)
The Changes view listed the same files in two different orders. The tree rail put directories before files at each level of the path. The scrolling diff compared the full path byte by byte. A root file such as .gitlab-ci.yml therefore opened the diff, but sat below every directory in the tree. Scrolling the diff did not walk the tree from top to bottom. Two sorts caused this. sortTree in git/diff-tree.ts sorted the tree. compareCheckoutDiffPaths in git/diff-order.ts sorted the flat list at ingest. The tree is now the only ordering authority. orderCheckoutDiffFiles builds the tree and reads the file sequence back out of it. compareCheckoutDiffPaths is deleted, so the two surfaces can no longer disagree. The daemon keeps its own whole-path sort, so daemons that are not updated also get this fix. Commit diffs keep the order that git gives them, because that panel shows no tree rail.
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import type { ParsedDiffFile } from "@/git/use-diff-query";
|
||||
|
||||
// Builds a directory hierarchy from the flat, path-sorted `ParsedDiffFile[]` the
|
||||
// Changes view renders. The tree renders on every form factor, consistent with
|
||||
// the Files explorer.
|
||||
// Builds a directory hierarchy from the `ParsedDiffFile[]` the Changes view
|
||||
// renders. The tree renders on every form factor, consistent with the Files
|
||||
// explorer.
|
||||
//
|
||||
// `sortTree` below is the single ordering authority for the Changes view. The
|
||||
// flat scrolling diff does not sort for itself — `orderCheckoutDiffFiles`
|
||||
// (diff-order.ts) builds this tree and reads its file sequence back out — so
|
||||
// changing `sortTree` reorders both surfaces together, by construction.
|
||||
//
|
||||
// Directory nodes are keyed by their FULL uncompressed path (e.g. "packages/app/src").
|
||||
// That path is the stable identity used to persist folder-collapse state, so the
|
||||
@@ -55,8 +60,8 @@ function sortTree(node: DiffTreeDirNode): void {
|
||||
// directories before files within a level
|
||||
return a.kind === "dir" ? -1 : 1;
|
||||
}
|
||||
// Plain ASCII comparison, matching compareCheckoutDiffPaths (diff-order.ts)
|
||||
// so the tree order is consistent with the rest of the Changes view.
|
||||
// Plain ASCII, not localeCompare: the order must not shift with the
|
||||
// device locale, and every surface derives from this comparison.
|
||||
if (a.name === b.name) return 0;
|
||||
return a.name < b.name ? -1 : 1;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user