git blame: Do not try to blame buffer if it has no file (#10985)

Release Notes:

- Fixed error messages being logged due to inline git blame not working
on an empty buffer that hasn't been saved yet.
This commit is contained in:
Thorsten Ball 2024-04-25 15:02:19 +02:00 committed by GitHub
parent 019821d62c
commit 7ec963664e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8982,6 +8982,10 @@ impl Editor {
return; return;
}; };
if buffer.read(cx).file().is_none() {
return;
}
let project = project.clone(); let project = project.clone();
let blame = cx.new_model(|cx| GitBlame::new(buffer, project, user_triggered, cx)); let blame = cx.new_model(|cx| GitBlame::new(buffer, project, user_triggered, cx));
self.blame_subscription = Some(cx.observe(&blame, |_, _, cx| cx.notify())); self.blame_subscription = Some(cx.observe(&blame, |_, _, cx| cx.notify()));