use anyhow::Result; use arc_swap::ArcSwap; use serde::{Deserialize, Deserializer, de}; use yazi_codegen::{DeserializeOver, DeserializeOver2}; use yazi_fs::{SortBy, SortFallback}; use yazi_shim::{arc_swap::IntoPointee, cell::SyncCell}; use super::{MgrRatio, MouseEvents}; #[derive(Debug, Deserialize, DeserializeOver, DeserializeOver2)] pub struct Mgr { pub ratio: SyncCell, // Sorting pub sort_by: SyncCell, pub sort_sensitive: SyncCell, pub sort_reverse: SyncCell, pub sort_dir_first: SyncCell, pub sort_translit: SyncCell, pub sort_fallback: SyncCell, // Display #[serde(deserialize_with = "deserialize_linemode")] pub linemode: ArcSwap, pub show_hidden: SyncCell, pub show_symlink: SyncCell, pub scrolloff: SyncCell, pub mouse_events: SyncCell, } fn deserialize_linemode<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; if s.is_empty() || s.len() > 20 { return Err(de::Error::custom("linemode must be between 1 and 20 characters.")); } Ok(s.into_pointee()) }