From 5e2aaf45a072f47cac3a7dd193f7a6b798fea422 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Sat, 13 May 2023 10:38:24 -0700 Subject: [PATCH 1/2] Fix repository initialization bug --- crates/editor/src/editor.rs | 15 +++++++++++++++ crates/project/src/worktree.rs | 13 ++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) 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..e5a1f9c93f 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,7 @@ 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 +3038,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; } From a6a4b846bc75554f3dda0984b930185395f1a2e3 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Sat, 13 May 2023 10:43:16 -0700 Subject: [PATCH 2/2] fmt --- crates/project/src/worktree.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index e5a1f9c93f..9b965eeea4 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -3030,7 +3030,12 @@ impl BackgroundScanner { Some(()) } - fn reload_repo_for_path(&self, path: &Path, snapshot: &mut LocalSnapshot, fs: &dyn Fs) -> Option<()> { + fn reload_repo_for_path( + &self, + path: &Path, + snapshot: &mut LocalSnapshot, + fs: &dyn Fs, + ) -> Option<()> { let scan_id = snapshot.scan_id; if path