git_ui: Fix open diff for untracked files when sorting by path enabled (#39862)

Fixes the `Open Diff` action for untracked files when the `sort_by_path`
setting is enabled. The `ProjectDiff` wasn't correctly moving the
multibuffer's cursor to the untracked file because, when that setting is
enabled, it's sort prefix is changed to the tracked files sort prefix, and that
wasn't accounted for in `move_to_entry`.

Before these changes, the `sort_prefix` field for `PathKey` was called `namespace`, it was renamed to be clearer what its purpose is.

Closes #39529 

Release Notes:

- Fixed 'Open Diff' action for untracked files when `sort_by_path` is
enabled

---------

Co-authored-by: David Kleingeld <davidsk@zed.dev>
This commit is contained in:
Dino
2025-10-09 14:34:52 +00:00
committed by GitHub
co-authored by David Kleingeld
parent dd5da592f0
commit c58931ac04
6 changed files with 103 additions and 43 deletions
@@ -1525,7 +1525,7 @@ fn test_set_excerpts_for_buffer_ordering(cx: &mut TestAppContext) {
cx,
)
});
let path1: PathKey = PathKey::namespaced(0, rel_path("root").into_arc());
let path1: PathKey = PathKey::with_sort_prefix(0, rel_path("root").into_arc());
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
multibuffer.update(cx, |multibuffer, cx| {
@@ -1620,7 +1620,7 @@ fn test_set_excerpts_for_buffer(cx: &mut TestAppContext) {
cx,
)
});
let path1: PathKey = PathKey::namespaced(0, rel_path("root").into_arc());
let path1: PathKey = PathKey::with_sort_prefix(0, rel_path("root").into_arc());
let buf2 = cx.new(|cx| {
Buffer::local(
indoc! {
@@ -1639,7 +1639,7 @@ fn test_set_excerpts_for_buffer(cx: &mut TestAppContext) {
cx,
)
});
let path2 = PathKey::namespaced(1, rel_path("root").into_arc());
let path2 = PathKey::with_sort_prefix(1, rel_path("root").into_arc());
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
multibuffer.update(cx, |multibuffer, cx| {
@@ -1816,7 +1816,7 @@ fn test_set_excerpts_for_buffer_rename(cx: &mut TestAppContext) {
cx,
)
});
let path: PathKey = PathKey::namespaced(0, rel_path("root").into_arc());
let path: PathKey = PathKey::with_sort_prefix(0, rel_path("root").into_arc());
let buf2 = cx.new(|cx| {
Buffer::local(
indoc! {