mirror of
https://github.com/zed-industries/zed.git
synced 2026-07-10 00:13:29 +00:00
agent_ui: Alphabetically sort edited files in the panel & review view (#47300)
This makes the ordering of files consistent with the Git diff view. Release Notes: - N/A
This commit is contained in:
parent
1b0771eb9c
commit
8fb5587ed8
2 changed files with 21 additions and 4 deletions
|
|
@ -5600,13 +5600,21 @@ impl AcpThreadView {
|
|||
) -> impl IntoElement {
|
||||
let editor_bg_color = cx.theme().colors().editor_background;
|
||||
|
||||
// Sort edited files alphabetically for consistency with Git diff view
|
||||
let mut sorted_buffers: Vec<_> = changed_buffers.iter().collect();
|
||||
sorted_buffers.sort_by(|(buffer_a, _), (buffer_b, _)| {
|
||||
let path_a = buffer_a.read(cx).file().map(|f| f.path().clone());
|
||||
let path_b = buffer_b.read(cx).file().map(|f| f.path().clone());
|
||||
path_a.cmp(&path_b)
|
||||
});
|
||||
|
||||
v_flex()
|
||||
.id("edited_files_list")
|
||||
.max_h_40()
|
||||
.overflow_y_scroll()
|
||||
.children(
|
||||
changed_buffers
|
||||
.iter()
|
||||
sorted_buffers
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.flat_map(|(index, (buffer, diff))| {
|
||||
let file = buffer.read(cx).file()?;
|
||||
|
|
|
|||
|
|
@ -131,6 +131,15 @@ impl AgentDiffPane {
|
|||
.action_log()
|
||||
.read(cx)
|
||||
.changed_buffers(cx);
|
||||
|
||||
// Sort edited files alphabetically for consistency with Git diff view
|
||||
let mut sorted_buffers: Vec<_> = changed_buffers.iter().collect();
|
||||
sorted_buffers.sort_by(|(buffer_a, _), (buffer_b, _)| {
|
||||
let path_a = buffer_a.read(cx).file().map(|f| f.path().clone());
|
||||
let path_b = buffer_b.read(cx).file().map(|f| f.path().clone());
|
||||
path_a.cmp(&path_b)
|
||||
});
|
||||
|
||||
let mut paths_to_delete = self
|
||||
.multibuffer
|
||||
.read(cx)
|
||||
|
|
@ -138,7 +147,7 @@ impl AgentDiffPane {
|
|||
.cloned()
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
for (buffer, diff_handle) in changed_buffers {
|
||||
for (buffer, diff_handle) in sorted_buffers {
|
||||
if buffer.read(cx).file().is_none() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -168,7 +177,7 @@ impl AgentDiffPane {
|
|||
multibuffer_context_lines(cx),
|
||||
cx,
|
||||
);
|
||||
multibuffer.add_diff(diff_handle, cx);
|
||||
multibuffer.add_diff(diff_handle.clone(), cx);
|
||||
(was_empty, is_excerpt_newly_added)
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue