Only keep one blame up-to-date (#11274)

I was experiencing hang, and we blamed it on spawning a few hundred git
processes
simultaneously.

cc @MrNugget

Release Notes:

- Fixed slowness with hundreds of buffers open doing git blame.
This commit is contained in:
Conrad Irwin 2024-05-01 16:25:26 -06:00 committed by GitHub
parent eb0f1e71f7
commit 3b5fd4ea66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 5 deletions

View file

@ -9053,8 +9053,11 @@ impl Editor {
return;
}
let focused = self.focus_handle(cx).contains_focused(cx);
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, focused, cx));
self.blame_subscription = Some(cx.observe(&blame, |_, _, cx| cx.notify()));
self.blame = Some(blame);
}
@ -10064,6 +10067,10 @@ impl Editor {
let rename_editor_focus_handle = rename.editor.read(cx).focus_handle.clone();
cx.focus(&rename_editor_focus_handle);
} else {
if let Some(blame) = self.blame.as_ref() {
blame.update(cx, GitBlame::focus)
}
self.blink_manager.update(cx, BlinkManager::enable);
self.show_cursor_names(cx);
self.buffer.update(cx, |buffer, cx| {
@ -10084,6 +10091,10 @@ impl Editor {
self.blink_manager.update(cx, BlinkManager::disable);
self.buffer
.update(cx, |buffer, cx| buffer.remove_active_selections(cx));
if let Some(blame) = self.blame.as_ref() {
blame.update(cx, GitBlame::blur)
}
self.hide_context_menu(cx);
hide_hover(self, cx);
cx.emit(EditorEvent::Blurred);