Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

assistant2: Allow adding directories as context that contain non-UTF8 files (#26135)

Bennet Bo Fennera602c50a6c6e
diff --git a/crates/assistant2/src/context_store.rs b/crates/assistant2/src/context_store.rs
index f527f5a7d30..5922f87ca47 100644
--- a/crates/assistant2/src/context_store.rs
+++ b/crates/assistant2/src/context_store.rs
@@ -208,12 +208,18 @@ impl ContextStore {
let mut text_tasks = Vec::new();
this.update(&mut cx, |_, cx| {
for (path, buffer_entity) in files.into_iter().zip(buffers) {
- let buffer_entity = buffer_entity?;
- let buffer = buffer_entity.read(cx);
- let (buffer_info, text_task) =
- collect_buffer_info_and_text(path, buffer_entity, buffer, cx.to_async());
- buffer_infos.push(buffer_info);
- text_tasks.push(text_task);
+ // Skip all binary files and other non-UTF8 files
+ if let Ok(buffer_entity) = buffer_entity {
+ let buffer = buffer_entity.read(cx);
+ let (buffer_info, text_task) = collect_buffer_info_and_text(
+ path,
+ buffer_entity,
+ buffer,
+ cx.to_async(),
+ );
+ buffer_infos.push(buffer_info);
+ text_tasks.push(text_task);
+ }
}
anyhow::Ok(())
})??;