From dc465839e1d300a0aeeecaf31a64d1f1177738b8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 10 May 2022 11:25:51 -0700 Subject: [PATCH] Round sidebar panels' widths to whole numbers of pixels Co-authored-by: Nathan Sobo --- crates/workspace/src/sidebar.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/workspace/src/sidebar.rs b/crates/workspace/src/sidebar.rs index bc7314e732..c9cbcbb4fb 100644 --- a/crates/workspace/src/sidebar.rs +++ b/crates/workspace/src/sidebar.rs @@ -106,10 +106,12 @@ impl Sidebar { .with_cursor_style(CursorStyle::ResizeLeftRight) .on_drag(move |delta, cx| { let prev_width = *actual_width.borrow(); - match side { - Side::Left => *custom_width.borrow_mut() = 0f32.max(prev_width + delta.x()), - Side::Right => *custom_width.borrow_mut() = 0f32.max(prev_width - delta.x()), - } + *custom_width.borrow_mut() = 0f32 + .max(match side { + Side::Left => prev_width + delta.x(), + Side::Right => prev_width - delta.x(), + }) + .round(); cx.notify(); })