Fix divide by 0 in terminal

Mikayla Maki created

Fix fail to remove contact in contact list

Change summary

crates/collab_ui/src/contact_list.rs  | 12 ++++++++++--
crates/terminal/src/mappings/mouse.rs |  3 +++
2 files changed, 13 insertions(+), 2 deletions(-)

Detailed changes

crates/collab_ui/src/contact_list.rs 🔗

@@ -316,12 +316,20 @@ impl ContactList {
             github_login
         );
         let mut answer = cx.prompt(PromptLevel::Warning, &prompt_message, &["Remove", "Cancel"]);
+        let window_id = cx.window_id();
         cx.spawn(|_, mut cx| async move {
             if answer.next().await == Some(0) {
-                user_store
+                if let Err(e) = user_store
                     .update(&mut cx, |store, cx| store.remove_contact(user_id, cx))
                     .await
-                    .unwrap();
+                {
+                    cx.prompt(
+                        window_id,
+                        PromptLevel::Info,
+                        &format!("Failed to remove contact: {}", e),
+                        &["Ok"],
+                    );
+                }
             }
         })
         .detach();

crates/terminal/src/mappings/mouse.rs 🔗

@@ -186,6 +186,9 @@ pub fn mouse_moved_report(point: Point, e: &MouseMovedEvent, mode: TermMode) ->
 }
 
 pub fn mouse_side(pos: Vector2F, cur_size: TerminalSize) -> alacritty_terminal::index::Direction {
+    if cur_size.cell_width as usize == 0 {
+        return Side::Right;
+    }
     let x = pos.0.x() as usize;
     let cell_x = x.saturating_sub(cur_size.cell_width as usize) % cur_size.cell_width as usize;
     let half_cell_width = (cur_size.cell_width / 2.0) as usize;