From 2cd21d1da85babd94d481378f18cd403190dd829 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 27 Aug 2021 16:30:43 +0200 Subject: [PATCH] Ensure sidebar width never goes below 0 --- zed/src/workspace/sidebar.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zed/src/workspace/sidebar.rs b/zed/src/workspace/sidebar.rs index fd660bfdbb..d726386801 100644 --- a/zed/src/workspace/sidebar.rs +++ b/zed/src/workspace/sidebar.rs @@ -127,9 +127,10 @@ impl Sidebar { .boxed() }) .on_drag(move |delta, cx| { + let prev_width = *width.borrow(); match side { - Side::Left => *width.borrow_mut() += delta.x(), - Side::Right => *width.borrow_mut() -= delta.x(), + Side::Left => *width.borrow_mut() = 0f32.max(prev_width + delta.x()), + Side::Right => *width.borrow_mut() = 0f32.max(prev_width - delta.x()), } cx.notify();