From 8debea80f34060d66c94e54aab95b683251f4b75 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 22 Aug 2024 19:04:03 +0300 Subject: [PATCH] Deduplicate /tab all buffers inserted (#16681) Closes https://github.com/zed-industries/zed/issues/16678 Release Notes: - Fixed `/tab all` inserting duplicate buffers ([!16678](https://github.com/zed-industries/zed/issues/16678)) --- crates/assistant/src/slash_command/tab_command.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/assistant/src/slash_command/tab_command.rs b/crates/assistant/src/slash_command/tab_command.rs index 0d8559896ba5c4e4584cf4618aecb9c8e8d94478..4e055e1c6bd2cf9426a2d40188a7f1ed06589342 100644 --- a/crates/assistant/src/slash_command/tab_command.rs +++ b/crates/assistant/src/slash_command/tab_command.rs @@ -197,6 +197,7 @@ fn tab_items_for_queries( } let mut timestamps_by_entity_id = HashMap::default(); + let mut visited_buffers = HashSet::default(); let mut open_buffers = Vec::new(); for pane in workspace.panes() { @@ -211,9 +212,11 @@ fn tab_items_for_queries( if let Some(timestamp) = timestamps_by_entity_id.get(&editor.entity_id()) { - let snapshot = buffer.read(cx).snapshot(); - let full_path = snapshot.resolve_file_path(cx, true); - open_buffers.push((full_path, snapshot, *timestamp)); + if visited_buffers.insert(buffer.read(cx).remote_id()) { + let snapshot = buffer.read(cx).snapshot(); + let full_path = snapshot.resolve_file_path(cx, true); + open_buffers.push((full_path, snapshot, *timestamp)); + } } } }