diff --git a/Cargo.lock b/Cargo.lock index 4d1d6a843b40f84fc96930378d76c6018bbdd0d3..d0ccc16795a4d4def93f45eddfe9d50fae0b401d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -637,6 +637,7 @@ dependencies = [ "ui", "util", "workspace", + "worktree", ] [[package]] diff --git a/crates/assistant2/src/context_picker/file_context_picker.rs b/crates/assistant2/src/context_picker/file_context_picker.rs index b68ae871451d48c4a7f8b3a401bed95bb17fea38..757249dbea59c1af76db14ee032c329623c2959c 100644 --- a/crates/assistant2/src/context_picker/file_context_picker.rs +++ b/crates/assistant2/src/context_picker/file_context_picker.rs @@ -124,7 +124,7 @@ impl FileContextPickerDelegate { let file_matches = project.worktrees(cx).flat_map(|worktree| { let worktree = worktree.read(cx); let path_prefix: Arc = worktree.root_name().into(); - worktree.files(true, 0).map(move |entry| PathMatch { + worktree.files(false, 0).map(move |entry| PathMatch { score: 0., positions: Vec::new(), worktree_id: worktree.id().to_usize(), diff --git a/crates/assistant_slash_commands/Cargo.toml b/crates/assistant_slash_commands/Cargo.toml index 5987e85cada5a5467812e904dd34bc7a738ae58c..25d762223dede4627abd22a4527be4f7d4b839b6 100644 --- a/crates/assistant_slash_commands/Cargo.toml +++ b/crates/assistant_slash_commands/Cargo.toml @@ -45,6 +45,7 @@ toml.workspace = true ui.workspace = true util.workspace = true workspace.workspace = true +worktree.workspace = true [dev-dependencies] env_logger.workspace = true diff --git a/crates/assistant_slash_commands/src/file_command.rs b/crates/assistant_slash_commands/src/file_command.rs index 10d1d88ae9e219f22e1054043aff41b26c9b3c92..d898d82bc3f538235374cce47b1518a4cf9c0aa3 100644 --- a/crates/assistant_slash_commands/src/file_command.rs +++ b/crates/assistant_slash_commands/src/file_command.rs @@ -20,6 +20,7 @@ use std::{ use ui::prelude::*; use util::ResultExt; use workspace::Workspace; +use worktree::ChildEntriesOptions; pub struct FileSlashCommand; @@ -42,7 +43,13 @@ impl FileSlashCommand { .chain(project.worktrees(cx).flat_map(|worktree| { let worktree = worktree.read(cx); let id = worktree.id(); - worktree.child_entries(Path::new("")).map(move |entry| { + let options = ChildEntriesOptions { + include_files: true, + include_dirs: true, + include_ignored: false, + }; + let entries = worktree.child_entries_with_options(Path::new(""), options); + entries.map(move |entry| { ( project::ProjectPath { worktree_id: id, diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index f8336484a303c12484d89cc20f698f3315eef223..9a3362bd463c621029d2ccbada5b8b16446f2446 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -2724,14 +2724,27 @@ impl Snapshot { } pub fn child_entries<'a>(&'a self, parent_path: &'a Path) -> ChildEntriesIter<'a> { + let options = ChildEntriesOptions { + include_files: true, + include_dirs: true, + include_ignored: true, + }; + self.child_entries_with_options(parent_path, options) + } + + pub fn child_entries_with_options<'a>( + &'a self, + parent_path: &'a Path, + options: ChildEntriesOptions, + ) -> ChildEntriesIter<'a> { let mut cursor = self.entries_by_path.cursor(&()); cursor.seek(&TraversalTarget::path(parent_path), Bias::Right, &()); let traversal = Traversal { snapshot: self, cursor, - include_files: true, - include_dirs: true, - include_ignored: true, + include_files: options.include_files, + include_dirs: options.include_dirs, + include_ignored: options.include_ignored, }; ChildEntriesIter { traversal, @@ -6054,6 +6067,12 @@ impl<'a, 'b> SeekTarget<'a, PathSummary, TraversalProgress<'a>> for Traver } } +pub struct ChildEntriesOptions { + pub include_files: bool, + pub include_dirs: bool, + pub include_ignored: bool, +} + pub struct ChildEntriesIter<'a> { parent_path: &'a Path, traversal: Traversal<'a>,