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: Fix issue with included directories in context picker (#27833)

Bennet Bo Fennerd1db6d678215
diff --git a/crates/assistant2/src/context_picker/file_context_picker.rs b/crates/assistant2/src/context_picker/file_context_picker.rs
index a96d0f986ca..8dca313fd2f 100644
--- a/crates/assistant2/src/context_picker/file_context_picker.rs
+++ b/crates/assistant2/src/context_picker/file_context_picker.rs
@@ -321,10 +321,7 @@ pub fn render_file_context_entry(
let added = context_store.upgrade().and_then(|context_store| {
if is_directory {
- context_store
- .read(cx)
- .includes_directory(path)
- .map(FileInclusion::Direct)
+ context_store.read(cx).includes_directory(path)
} else {
context_store.read(cx).will_include_file_path(path, cx)
}
diff --git a/crates/assistant2/src/context_store.rs b/crates/assistant2/src/context_store.rs
index e4ef3da196d..b9af3c1ce59 100644
--- a/crates/assistant2/src/context_store.rs
+++ b/crates/assistant2/src/context_store.rs
@@ -180,14 +180,15 @@ impl ContextStore {
return Task::ready(Err(anyhow!("failed to read project")));
};
- let already_included = if let Some(context_id) = self.includes_directory(&project_path.path)
- {
- if remove_if_exists {
- self.remove_context(context_id);
+ let already_included = match self.includes_directory(&project_path.path) {
+ Some(FileInclusion::Direct(context_id)) => {
+ if remove_if_exists {
+ self.remove_context(context_id);
+ }
+ true
}
- true
- } else {
- false
+ Some(FileInclusion::InDirectory(_)) => true,
+ None => false,
};
if already_included {
return Task::ready(Ok(()));
@@ -509,8 +510,12 @@ impl ContextStore {
None
}
- pub fn includes_directory(&self, path: &Path) -> Option<ContextId> {
- self.directories.get(path).copied()
+ pub fn includes_directory(&self, path: &Path) -> Option<FileInclusion> {
+ if let Some(context_id) = self.directories.get(path) {
+ return Some(FileInclusion::Direct(*context_id));
+ }
+
+ self.will_include_file_path_via_directory(path)
}
pub fn included_symbol(&self, symbol_id: &ContextSymbolId) -> Option<ContextId> {