From cbe0fd5c73c0ba1af354c374eb85e39c1040c184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Wed, 13 Sep 2023 01:13:10 +0800 Subject: [PATCH] fix: image position calculation (#144) --- config/src/manager/layout.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/src/manager/layout.rs b/config/src/manager/layout.rs index 8ea2fdba9..d7df50093 100644 --- a/config/src/manager/layout.rs +++ b/config/src/manager/layout.rs @@ -39,8 +39,10 @@ impl ManagerLayout { pub fn preview_rect(&self) -> Rect { let WindowSize { columns, rows, .. } = Term::size(); - let x = (columns as u32 * (self.parent + self.current) / self.all) as u16; - let width = (columns as u32 * self.preview / self.all) as u16; + let width = (columns as u32 * self.preview) as f64 / self.all as f64; + let width = if width.fract() > 0.5 { width.ceil() as u16 } else { width.floor() as u16 }; + + let x = columns.saturating_sub(width); Rect { x: x.saturating_add(PREVIEW_BORDER / 2),