editor: Deduplicate multibuffer blame error messages (#48013)

Lukas Wirth created

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Change summary

crates/editor/src/git/blame.rs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

Detailed changes

crates/editor/src/git/blame.rs 🔗

@@ -610,21 +610,23 @@ impl GitBlame {
                 cx.notify();
                 if !all_errors.is_empty() {
                     this.project.update(cx, |_, cx| {
+                        let all_errors = all_errors
+                            .into_iter()
+                            .map(|e| format!("{e:#}"))
+                            .dedup()
+                            .collect::<Vec<_>>();
+                        let all_errors = all_errors.join(", ");
                         if this.user_triggered {
-                            log::error!("failed to get git blame data: {all_errors:?}");
-                            let notification = all_errors
-                                .into_iter()
-                                .format_with(",", |e, f| f(&format_args!("{:#}", e)))
-                                .to_string();
+                            log::error!("failed to get git blame data: {all_errors}");
                             cx.emit(project::Event::Toast {
                                 notification_id: "git-blame".into(),
-                                message: notification,
+                                message: all_errors,
                                 link: None,
                             });
                         } else {
                             // If we weren't triggered by a user, we just log errors in the background, instead of sending
                             // notifications.
-                            log::debug!("failed to get git blame data: {all_errors:?}");
+                            log::debug!("failed to get git blame data: {all_errors}");
                         }
                     })
                 }