Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Omit gitignored files from context file picker (#23777)
João Marcos2b160f4f3cc7
diff --git a/Cargo.lock b/Cargo.lockindex 4d1d6a843b4..d0ccc16795a 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.rsindex b68ae871451..757249dbea5 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<str> = 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.tomlindex 5987e85cada..25d762223de 100644--- a/crates/assistant_slash_commands/Cargo.toml+++ b/crates/assistant_slash_commands/Cargo.toml@@ -45,6 +45,7 @@ toml.workspace = trueui.workspace = trueutil.workspace = trueworkspace.workspace = true+worktree.workspace = true[dev-dependencies]env_logger.workspace = truediff --git a/crates/assistant_slash_commands/src/file_command.rs b/crates/assistant_slash_commands/src/file_command.rsindex 10d1d88ae9e..d898d82bc3f 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.rsindex f8336484a30..9a3362bd463 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<Unit>, 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>,