assistant2: Fix issue with included directories in context picker (#27833)

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2025-04-01 11:44:06 +02:00 committed by GitHub
parent 5509e0141a
commit d1db6d6782
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 13 deletions

View file

@ -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)
}

View file

@ -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> {