assistant2: Allow adding directories as context that contain non-UTF8 files (#26135)
We would previously return an error if there was at least one non-UTF8 file. Now we just ignore them and only add text files. If no text files are found we show an error. Release Notes: - N/A
This commit is contained in:
parent
728c161e8d
commit
a602c50a6c
1 changed files with 12 additions and 6 deletions
|
@ -208,13 +208,19 @@ impl ContextStore {
|
||||||
let mut text_tasks = Vec::new();
|
let mut text_tasks = Vec::new();
|
||||||
this.update(&mut cx, |_, cx| {
|
this.update(&mut cx, |_, cx| {
|
||||||
for (path, buffer_entity) in files.into_iter().zip(buffers) {
|
for (path, buffer_entity) in files.into_iter().zip(buffers) {
|
||||||
let buffer_entity = buffer_entity?;
|
// Skip all binary files and other non-UTF8 files
|
||||||
|
if let Ok(buffer_entity) = buffer_entity {
|
||||||
let buffer = buffer_entity.read(cx);
|
let buffer = buffer_entity.read(cx);
|
||||||
let (buffer_info, text_task) =
|
let (buffer_info, text_task) = collect_buffer_info_and_text(
|
||||||
collect_buffer_info_and_text(path, buffer_entity, buffer, cx.to_async());
|
path,
|
||||||
|
buffer_entity,
|
||||||
|
buffer,
|
||||||
|
cx.to_async(),
|
||||||
|
);
|
||||||
buffer_infos.push(buffer_info);
|
buffer_infos.push(buffer_info);
|
||||||
text_tasks.push(text_task);
|
text_tasks.push(text_task);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
})??;
|
})??;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue