Merge pull request #2469 from zed-industries/fix-git-init-bug

Fix repository initialization bug
This commit is contained in:
Mikayla Maki 2023-05-13 10:47:55 -07:00 committed by GitHub
commit db87e83bad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 3 deletions

View file

@ -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::<Settings, _>(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);

View file

@ -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;
}