From 64c6cdf07250d3919db66aa5c08de97071d6bb79 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sun, 20 Aug 2023 07:10:10 +0800 Subject: [PATCH] fix: regression that caused TUI tearing when previewing an image --- adaptor/src/adaptor.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adaptor/src/adaptor.rs b/adaptor/src/adaptor.rs index 9b5a95d5..bff94b6f 100644 --- a/adaptor/src/adaptor.rs +++ b/adaptor/src/adaptor.rs @@ -24,6 +24,10 @@ impl Adaptor { path = cache.as_path(); } + if IMAGE_SHOWN.swap(true, Ordering::Relaxed) { + Self::image_hide(rect).ok(); + } + match PREVIEW.adaptor { PreviewAdaptor::Kitty => Kitty::image_show(path, rect).await, PreviewAdaptor::Iterm2 => Iterm2::image_show(path, rect).await, @@ -31,9 +35,7 @@ impl Adaptor { _ => Ok(if let Some(tx) = &*UEBERZUG { tx.send(Some((path.to_path_buf(), rect)))?; }), - }?; - - Ok(IMAGE_SHOWN.store(true, Ordering::Relaxed)) + } } pub fn image_hide(rect: Rect) -> Result<()> {