From 2cecdab47d5211ca00cc7b084acdf0eb30a9d772 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 6 Feb 2026 00:02:06 -0700 Subject: [PATCH] Don't watch parent directory of global gitexcludes file (#48408) Closes: #48560 Release Notes: - Fixed an issue where Zed would try to open all edited files in ~ if your git config had a globalexludes in ~ that did not exist. --------- Co-authored-by: Cole Miller --- crates/editor/src/editor_tests.rs | 4 ++++ crates/file_finder/src/file_finder_tests.rs | 4 +++- crates/worktree/src/worktree.rs | 16 ++++++---------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 39d8f59d87b7ea212d55ec8f9d30e3618628cdf1..8487b60690b0a67f43d1cc61959e597f2cfc0424 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -7853,6 +7853,7 @@ async fn test_paste_content_from_other_app(cx: &mut TestAppContext) { let mut cx = EditorTestContext::new(cx).await; cx.update_buffer(|buffer, cx| buffer.set_language(Some(rust_lang()), cx)); + cx.run_until_parked(); cx.set_state(indoc! {" fn a() { @@ -22342,6 +22343,7 @@ async fn test_active_indent_guide_respect_indented_range(cx: &mut TestAppContext s.select_ranges([Point::new(1, 0)..Point::new(1, 0)]) }); }); + cx.run_until_parked(); assert_indent_guides( 0..4, @@ -22358,6 +22360,7 @@ async fn test_active_indent_guide_respect_indented_range(cx: &mut TestAppContext s.select_ranges([Point::new(2, 0)..Point::new(2, 0)]) }); }); + cx.run_until_parked(); assert_indent_guides( 0..4, @@ -22374,6 +22377,7 @@ async fn test_active_indent_guide_respect_indented_range(cx: &mut TestAppContext s.select_ranges([Point::new(3, 0)..Point::new(3, 0)]) }); }); + cx.run_until_parked(); assert_indent_guides( 0..4, diff --git a/crates/file_finder/src/file_finder_tests.rs b/crates/file_finder/src/file_finder_tests.rs index e8d85921a18643277a76442e9432afdfeecd44bd..1b1421e8b8978a55d89db746b894486888342a65 100644 --- a/crates/file_finder/src/file_finder_tests.rs +++ b/crates/file_finder/src/file_finder_tests.rs @@ -2831,8 +2831,10 @@ async fn test_selected_match_stays_selected_after_matches_refreshed(cx: &mut gpu .create_file(Path::new(&filename), Default::default()) .await .expect("unable to create file"); + // Wait for each file system event to be fully processed before adding the next + cx.executor().advance_clock(FS_WATCH_LATENCY); + cx.run_until_parked(); } - cx.executor().advance_clock(FS_WATCH_LATENCY); // file_13.txt is still selected picker.update(cx, |finder, _| { diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index fd8aa464060ce65a15cd63b45a833098e0fdbc83..77a9f48f33395aa5307b3cd6a63007408e9033ac 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -3800,8 +3800,9 @@ impl BackgroundScanner { log::trace!("containing git repository: {containing_git_repository:?}"); + let global_gitignore_file = paths::global_gitignore_path(); let mut global_gitignore_events = if let Some(global_gitignore_path) = - &paths::global_gitignore_path() + &global_gitignore_file && scanning_enabled { let is_file = self.fs.is_file(&global_gitignore_path).await; @@ -3813,9 +3814,7 @@ impl BackgroundScanner { } else { None }; - if is_file - || matches!(global_gitignore_path.parent(), Some(path) if self.fs.is_dir(path).await) - { + if is_file { self.fs .watch(global_gitignore_path, FS_WATCH_LATENCY) .await @@ -3931,12 +3930,9 @@ impl BackgroundScanner { self.process_events(paths.into_iter().filter(|e| e.kind.is_some()).map(Into::into).collect()).await; } - paths = global_gitignore_events.next().fuse() => { - match paths.as_deref() { - Some([event, ..]) => { - self.update_global_gitignore(&event.path).await; - } - _ => (), + _ = global_gitignore_events.next().fuse() => { + if let Some(path) = &global_gitignore_file { + self.update_global_gitignore(&path).await; } } }