From c6ad241322ac81ae31d7dff7478c76fb69a3e796 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:03:07 -0700 Subject: [PATCH] Ensure panel and pane sizes are integral (cherry-pick #8619) (#8621) Cherry-picked Ensure panel and pane sizes are integral (#8619) Fixes: #8050 For some reason that we didn't investigate, if you have view caching enabled, and you have non-integer sized bounds, and you are right aligning things, the co-ordinates can differ by +/- 1px when using the cached view. The easiest fix for now is to just not do that. Co-Authored-By: Antonio Release Notes: - Fixed the pane icons flickering ([#8050](https://github.com/zed-industries/zed/issues/8050)). Co-authored-by: Antonio Co-authored-by: Conrad Irwin Co-authored-by: Antonio --- crates/collab_ui/src/chat_panel.rs | 2 +- crates/collab_ui/src/collab_panel.rs | 2 +- crates/collab_ui/src/notification_panel.rs | 2 +- crates/project_panel/src/project_panel.rs | 2 +- crates/terminal_view/src/terminal_panel.rs | 4 ++-- crates/workspace/src/dock.rs | 2 +- crates/workspace/src/pane_group.rs | 3 ++- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs index 5c961e45350c6b1bf46ae11de37d0b05c4c9f53e..6b8dfe223609edc57feb6cf321cbe6d7b8db707d 100644 --- a/crates/collab_ui/src/chat_panel.rs +++ b/crates/collab_ui/src/chat_panel.rs @@ -204,7 +204,7 @@ impl ChatPanel { let panel = Self::new(workspace, cx); if let Some(serialized_panel) = serialized_panel { panel.update(cx, |panel, cx| { - panel.width = serialized_panel.width; + panel.width = serialized_panel.width.map(|r| r.round()); cx.notify(); }); } diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index d84fa78d4f73a0d126f62b34bc44293cb36d23c2..e953127841c960efde727881c282d645552c7bb0 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -323,7 +323,7 @@ impl CollabPanel { let panel = CollabPanel::new(workspace, cx); if let Some(serialized_panel) = serialized_panel { panel.update(cx, |panel, cx| { - panel.width = serialized_panel.width; + panel.width = serialized_panel.width.map(|w| w.round()); panel.collapsed_channels = serialized_panel .collapsed_channels .unwrap_or_else(|| Vec::new()); diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs index 54699a34404b39edc11b5dffd9e80b351dee4fd2..1b74e2abbeca262094cb145df826dc64dbe86a8b 100644 --- a/crates/collab_ui/src/notification_panel.rs +++ b/crates/collab_ui/src/notification_panel.rs @@ -183,7 +183,7 @@ impl NotificationPanel { let panel = Self::new(workspace, cx); if let Some(serialized_panel) = serialized_panel { panel.update(cx, |panel, cx| { - panel.width = serialized_panel.width; + panel.width = serialized_panel.width.map(|w| w.round()); cx.notify(); }); } diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 3744a36c00f61e0c14442a0075c4784c64dff820..b2d036f585efd6d202d2ce820895192769f9973a 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -338,7 +338,7 @@ impl ProjectPanel { let panel = ProjectPanel::new(workspace, cx); if let Some(serialized_panel) = serialized_panel { panel.update(cx, |panel, cx| { - panel.width = serialized_panel.width; + panel.width = serialized_panel.width.map(|px| px.round()); cx.notify(); }); } diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 9d820aad1c6726fc738cb72cd77018edd76f02b1..4ab3d371e0ff319b0e25add7c8c8bdc54ba8dbd6 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -192,8 +192,8 @@ impl TerminalPanel { let items = if let Some(serialized_panel) = serialized_panel.as_ref() { panel.update(cx, |panel, cx| { cx.notify(); - panel.height = serialized_panel.height; - panel.width = serialized_panel.width; + panel.height = serialized_panel.height.map(|h| h.round()); + panel.width = serialized_panel.width.map(|w| w.round()); panel.pane.update(cx, |_, cx| { serialized_panel .items diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index afedb7645b2b02b2813c623000d1ff5c6c2a969f..70059e47b6135c5bca10f37f8861bf7631bf9631 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -522,7 +522,7 @@ impl Dock { pub fn resize_active_panel(&mut self, size: Option, cx: &mut ViewContext) { if let Some(entry) = self.panel_entries.get_mut(self.active_panel_index) { - let size = size.map(|size| size.max(RESIZE_HANDLE_SIZE)); + let size = size.map(|size| size.max(RESIZE_HANDLE_SIZE).round()); entry.panel.set_size(size, cx); cx.notify(); } diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index 6a2a8e8094b65524a51b6ed02cb637409d6862ca..6f55dc800e3dcd4ff5b6e18edbe9c2d6b53026ec 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -883,7 +883,8 @@ mod element { let child_size = bounds .size - .apply_along(self.axis, |_| space_per_flex * child_flex); + .apply_along(self.axis, |_| space_per_flex * child_flex) + .map(|d| d.round()); let child_bounds = Bounds { origin,