mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: new option to suppress 0.4 deprecation warnings (#2027)
This commit is contained in:
parent
61cab0f30a
commit
ccf466d881
3 changed files with 10 additions and 2 deletions
|
|
@ -26,6 +26,10 @@ pub struct Manager {
|
||||||
pub scrolloff: u8,
|
pub scrolloff: u8,
|
||||||
pub mouse_events: MouseEvents,
|
pub mouse_events: MouseEvents,
|
||||||
pub title_format: String,
|
pub title_format: String,
|
||||||
|
|
||||||
|
// TODO: remove this in Yazi 0.4.2
|
||||||
|
#[serde(default)]
|
||||||
|
pub _v4_suppress_deprecation_warnings: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for Manager {
|
impl FromStr for Manager {
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,9 @@ impl<T: Into<yazi_fs::Cha>> From<T> for Cha {
|
||||||
fn from(cha: T) -> Self { Self(cha.into()) }
|
fn from(cha: T) -> Self { Self(cha.into()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn warn_deprecated(id: Option<&str>) {
|
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) {
|
if !WARNED.swap(true, std::sync::atomic::Ordering::Relaxed) {
|
||||||
let id = match id {
|
let id = match id {
|
||||||
Some(id) => format!("`{id}.yazi` plugin"),
|
Some(id) => format!("`{id}.yazi` plugin"),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
use yazi_config::MANAGER;
|
||||||
use yazi_macro::emit;
|
use yazi_macro::emit;
|
||||||
use yazi_shared::{Layer, event::Cmd};
|
use yazi_shared::{Layer, event::Cmd};
|
||||||
|
|
||||||
|
|
@ -23,6 +24,10 @@ impl AppProxy {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn notify(opt: NotifyOpt) {
|
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));
|
emit!(Call(Cmd::new("notify").with_any("option", opt), Layer::App));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue