diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 2bb9869e6d..b6d44397a9 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1248,6 +1248,16 @@ impl Editor { let soft_wrap_mode_override = (mode == EditorMode::SingleLine).then(|| settings::SoftWrap::None); + + let mut project_subscription = None; + if mode == EditorMode::Full && buffer.read(cx).is_singleton() { + if let Some(project) = project.as_ref() { + project_subscription = Some(cx.observe(project, |_, _, cx| { + cx.emit(Event::TitleChanged); + })) + } + } + let mut this = Self { handle: cx.weak_handle(), buffer: buffer.clone(), @@ -1304,6 +1314,11 @@ impl Editor { cx.observe_global::(Self::settings_changed), ], }; + + if let Some(project_subscription) = project_subscription { + this._subscriptions.push(project_subscription); + } + this.end_selection(cx); this.scroll_manager.show_scrollbar(cx); diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index c1f5178399..9b965eeea4 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -2973,7 +2973,7 @@ impl BackgroundScanner { fs_entry.is_ignored = ignore_stack.is_all(); snapshot.insert_entry(fs_entry, self.fs.as_ref()); - self.reload_repo_for_path(&path, &mut snapshot); + self.reload_repo_for_path(&path, &mut snapshot, self.fs.as_ref()); if let Some(scan_queue_tx) = &scan_queue_tx { let mut ancestor_inodes = snapshot.ancestor_inodes_for_path(&path); @@ -3030,7 +3030,12 @@ impl BackgroundScanner { Some(()) } - fn reload_repo_for_path(&self, path: &Path, snapshot: &mut LocalSnapshot) -> Option<()> { + fn reload_repo_for_path( + &self, + path: &Path, + snapshot: &mut LocalSnapshot, + fs: &dyn Fs, + ) -> Option<()> { let scan_id = snapshot.scan_id; if path @@ -3038,7 +3043,14 @@ impl BackgroundScanner { .any(|component| component.as_os_str() == *DOT_GIT) { let (entry_id, repo_ptr) = { - let (entry_id, repo) = snapshot.repo_for_metadata(&path)?; + let Some((entry_id, repo)) = snapshot.repo_for_metadata(&path) else { + let dot_git_dir = path.ancestors() + .skip_while(|ancestor| ancestor.file_name() != Some(&*DOT_GIT)) + .next()?; + + snapshot.build_repo(dot_git_dir.into(), fs); + return None; + }; if repo.full_scan_id == scan_id { return None; }