From ccf466d8812304de2abba15775a34f041ce21524 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, 11 Dec 2024 17:38:43 +0800 Subject: [PATCH] feat: new option to suppress 0.4 deprecation warnings (#2027) --- yazi-config/src/manager/manager.rs | 4 ++++ yazi-plugin/src/bindings/cha.rs | 3 +-- yazi-proxy/src/app.rs | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/yazi-config/src/manager/manager.rs b/yazi-config/src/manager/manager.rs index 923b7dc1..42e0171d 100644 --- a/yazi-config/src/manager/manager.rs +++ b/yazi-config/src/manager/manager.rs @@ -26,6 +26,10 @@ pub struct Manager { pub scrolloff: u8, pub mouse_events: MouseEvents, pub title_format: String, + + // TODO: remove this in Yazi 0.4.2 + #[serde(default)] + pub _v4_suppress_deprecation_warnings: bool, } impl FromStr for Manager { diff --git a/yazi-plugin/src/bindings/cha.rs b/yazi-plugin/src/bindings/cha.rs index b67c3248..de1b2bc8 100644 --- a/yazi-plugin/src/bindings/cha.rs +++ b/yazi-plugin/src/bindings/cha.rs @@ -18,10 +18,9 @@ impl> From for Cha { fn from(cha: T) -> Self { Self(cha.into()) } } -static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); - #[inline] fn warn_deprecated(id: Option<&str>) { + static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); if !WARNED.swap(true, std::sync::atomic::Ordering::Relaxed) { let id = match id { Some(id) => format!("`{id}.yazi` plugin"), diff --git a/yazi-proxy/src/app.rs b/yazi-proxy/src/app.rs index bef61e18..83302bbd 100644 --- a/yazi-proxy/src/app.rs +++ b/yazi-proxy/src/app.rs @@ -1,6 +1,7 @@ use std::time::Duration; use tokio::sync::oneshot; +use yazi_config::MANAGER; use yazi_macro::emit; use yazi_shared::{Layer, event::Cmd}; @@ -23,6 +24,10 @@ impl AppProxy { #[inline] pub fn notify(opt: NotifyOpt) { + if MANAGER._v4_suppress_deprecation_warnings && opt.title.contains("Deprecated") { + return; + } + emit!(Call(Cmd::new("notify").with_any("option", opt), Layer::App)); }