From 83b46c8230100487f5894bf1e80cf5a0c01049fd Mon Sep 17 00:00:00 2001 From: Ahmed Hassan Date: Wed, 30 Jul 2025 06:28:55 +0400 Subject: [PATCH] rerstore firmatting diffs --- cspell.json | 2 +- yazi-actor/src/mgr/search.rs | 7 +- yazi-fs/src/cha/cha.rs | 70 +++++++------------ yazi-parser/src/mgr/search.rs | 12 ++-- yazi-plugin/src/external/es.rs | 6 +- yazi-shared/src/url/url.rs | 119 ++++++++++----------------------- 6 files changed, 69 insertions(+), 147 deletions(-) diff --git a/cspell.json b/cspell.json index d51bd8bd..6cfa834e 100644 --- a/cspell.json +++ b/cspell.json @@ -1 +1 @@ -{"version":"0.2","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg","foldhash","tilded"],"language":"en"} +{"version":"0.2","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg","foldhash","tilded"],"language":"en"} \ No newline at end of file diff --git a/yazi-actor/src/mgr/search.rs b/yazi-actor/src/mgr/search.rs index afd4b2ac..6ed045f0 100644 --- a/yazi-actor/src/mgr/search.rs +++ b/yazi-actor/src/mgr/search.rs @@ -6,10 +6,7 @@ use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use yazi_config::popup::InputCfg; use yazi_fs::{FilesOp, cha::Cha}; use yazi_macro::{act, succ}; -use yazi_parser::{ - VoidOpt, - mgr::{SearchOpt, SearchOptVia}, -}; +use yazi_parser::{VoidOpt, mgr::{SearchOpt, SearchOptVia}}; use yazi_plugin::external; use yazi_proxy::{InputProxy, MgrProxy}; use yazi_shared::event::Data; @@ -123,4 +120,4 @@ impl Actor for SearchStop { } succ!(); } -} +} \ No newline at end of file diff --git a/yazi-fs/src/cha/cha.rs b/yazi-fs/src/cha/cha.rs index 7bf15f1f..b89e285a 100644 --- a/yazi-fs/src/cha/cha.rs +++ b/yazi-fs/src/cha/cha.rs @@ -1,7 +1,4 @@ -use std::{ - fs::{FileType, Metadata}, - time::SystemTime, -}; +use std::{fs::{FileType, Metadata}, time::SystemTime}; use yazi_macro::{unix_either, win_either}; use yazi_shared::url::Url; @@ -11,21 +8,21 @@ use crate::services; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Cha { - pub kind: ChaKind, - pub len: u64, + pub kind: ChaKind, + pub len: u64, pub atime: Option, pub btime: Option, #[cfg(unix)] pub ctime: Option, pub mtime: Option, #[cfg(unix)] - pub mode: libc::mode_t, + pub mode: libc::mode_t, #[cfg(unix)] - pub dev: libc::dev_t, + pub dev: libc::dev_t, #[cfg(unix)] - pub uid: libc::uid_t, + pub uid: libc::uid_t, #[cfg(unix)] - pub gid: libc::gid_t, + pub gid: libc::gid_t, #[cfg(unix)] pub nlink: libc::nlink_t, } @@ -33,23 +30,23 @@ pub struct Cha { impl Default for Cha { fn default() -> Self { Self { - kind: ChaKind::DUMMY, - len: 0, - atime: None, - btime: None, + kind: ChaKind::DUMMY, + len: 0, + atime: None, + btime: None, #[cfg(unix)] - ctime: None, - mtime: None, + ctime: None, + mtime: None, #[cfg(unix)] - mode: 0, + mode: 0, #[cfg(unix)] - dev: 0, + dev: 0, #[cfg(unix)] - uid: 0, + uid: 0, #[cfg(unix)] - gid: 0, + gid: 0, #[cfg(unix)] - nlink: 0, + nlink: 0, } } } @@ -132,10 +129,7 @@ impl Cha { fn from_just_meta(m: &Metadata) -> Self { #[cfg(unix)] - use std::{ - os::unix::{fs::MetadataExt, prelude::PermissionsExt}, - time::{Duration, UNIX_EPOCH}, - }; + use std::{os::unix::{fs::MetadataExt, prelude::PermissionsExt}, time::{Duration, UNIX_EPOCH}}; let mut kind = ChaKind::empty(); if m.is_dir() { @@ -184,9 +178,7 @@ impl Cha { impl Cha { #[inline] - pub const fn is_dir(&self) -> bool { - self.kind.contains(ChaKind::DIR) - } + pub const fn is_dir(&self) -> bool { self.kind.contains(ChaKind::DIR) } #[inline] pub const fn is_hidden(&self) -> bool { @@ -197,19 +189,13 @@ impl Cha { } #[inline] - pub const fn is_link(&self) -> bool { - self.kind.contains(ChaKind::LINK) - } + pub const fn is_link(&self) -> bool { self.kind.contains(ChaKind::LINK) } #[inline] - pub const fn is_orphan(&self) -> bool { - self.kind.contains(ChaKind::ORPHAN) - } + pub const fn is_orphan(&self) -> bool { self.kind.contains(ChaKind::ORPHAN) } #[inline] - pub const fn is_dummy(&self) -> bool { - self.kind.contains(ChaKind::DUMMY) - } + pub const fn is_dummy(&self) -> bool { self.kind.contains(ChaKind::DUMMY) } #[inline] pub const fn is_block(&self) -> bool { @@ -232,12 +218,8 @@ impl Cha { } #[inline] - pub const fn is_exec(&self) -> bool { - unix_either!(self.mode & libc::S_IXUSR != 0, false) - } + pub const fn is_exec(&self) -> bool { unix_either!(self.mode & libc::S_IXUSR != 0, false) } #[inline] - pub const fn is_sticky(&self) -> bool { - unix_either!(self.mode & libc::S_ISVTX != 0, false) - } -} + pub const fn is_sticky(&self) -> bool { unix_either!(self.mode & libc::S_ISVTX != 0, false) } +} \ No newline at end of file diff --git a/yazi-parser/src/mgr/search.rs b/yazi-parser/src/mgr/search.rs index 9d22fae3..c32805ad 100644 --- a/yazi-parser/src/mgr/search.rs +++ b/yazi-parser/src/mgr/search.rs @@ -4,9 +4,9 @@ use yazi_shared::{SStr, event::CmdCow}; #[derive(Debug)] pub struct SearchOpt { - pub via: SearchOptVia, - pub subject: SStr, - pub args: Vec, + pub via: SearchOptVia, + pub subject: SStr, + pub args: Vec, pub args_raw: SStr, } @@ -36,9 +36,7 @@ impl TryFrom for SearchOpt { } impl IntoLua for &SearchOpt { - fn into_lua(self, _: &Lua) -> mlua::Result { - Err("unsupported".into_lua_err()) - } + fn into_lua(self, _: &Lua) -> mlua::Result { Err("unsupported".into_lua_err()) } } // Via @@ -70,4 +68,4 @@ impl SearchOptVia { Self::Es => "es", } } -} +} \ No newline at end of file diff --git a/yazi-plugin/src/external/es.rs b/yazi-plugin/src/external/es.rs index ba509268..2d15f097 100644 --- a/yazi-plugin/src/external/es.rs +++ b/yazi-plugin/src/external/es.rs @@ -2,11 +2,7 @@ use std::path::Path; use std::process::Stdio; use anyhow::Result; -use tokio::{ - io::{AsyncBufReadExt, BufReader}, - process::{Child, Command}, - sync::mpsc::{self, UnboundedReceiver}, -}; +use tokio::{io::{AsyncBufReadExt, BufReader},process::{Child, Command},sync::mpsc::{self, UnboundedReceiver},}; use yazi_fs::File; use yazi_shared::url::Url; diff --git a/yazi-shared/src/url/url.rs b/yazi-shared/src/url/url.rs index 4b3c79ba..ed82b626 100644 --- a/yazi-shared/src/url/url.rs +++ b/yazi-shared/src/url/url.rs @@ -1,57 +1,37 @@ -use std::{ - borrow::Cow, - ffi::OsStr, - fmt::{Debug, Formatter}, - hash::BuildHasher, - ops::Deref, - path::{Path, PathBuf}, -}; +use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, hash::BuildHasher, ops::Deref, path::{Path, PathBuf}}; use percent_encoding::percent_decode; use serde::{Deserialize, Serialize}; use super::UrnBuf; -use crate::{ - IntoOsStr, - url::{Components, Display, Loc, Scheme}, -}; +use crate::{IntoOsStr, url::{Components, Display, Loc, Scheme}}; #[derive(Clone, Default, Eq, Ord, PartialOrd, PartialEq, Hash)] pub struct Url { - pub loc: Loc, + pub loc: Loc, pub scheme: Scheme, } impl Deref for Url { type Target = Loc; - fn deref(&self) -> &Self::Target { - &self.loc - } + fn deref(&self) -> &Self::Target { &self.loc } } impl From for Url { - fn from(loc: Loc) -> Self { - Self { loc, scheme: Scheme::Regular } - } + fn from(loc: Loc) -> Self { Self { loc, scheme: Scheme::Regular } } } impl From for Url { - fn from(path: PathBuf) -> Self { - Loc::from(path).into() - } + fn from(path: PathBuf) -> Self { Loc::from(path).into() } } impl From<&PathBuf> for Url { - fn from(path: &PathBuf) -> Self { - path.to_owned().into() - } + fn from(path: &PathBuf) -> Self { path.to_owned().into() } } impl From<&Path> for Url { - fn from(path: &Path) -> Self { - path.to_path_buf().into() - } + fn from(path: &Path) -> Self { path.to_path_buf().into() } } impl TryFrom<&[u8]> for Url { @@ -73,48 +53,34 @@ impl TryFrom<&[u8]> for Url { impl TryFrom<&str> for Url { type Error = anyhow::Error; - fn try_from(value: &str) -> Result { - value.as_bytes().try_into() - } + fn try_from(value: &str) -> Result { value.as_bytes().try_into() } } impl TryFrom for Url { type Error = anyhow::Error; - fn try_from(value: String) -> Result { - value.as_bytes().try_into() - } + fn try_from(value: String) -> Result { value.as_bytes().try_into() } } impl AsRef for Url { - fn as_ref(&self) -> &Url { - self - } + fn as_ref(&self) -> &Url { self } } // FIXME: remove impl AsRef for Url { - fn as_ref(&self) -> &Path { - &self.loc - } + fn as_ref(&self) -> &Path { &self.loc } } impl<'a> From<&'a Url> for Cow<'a, Url> { - fn from(url: &'a Url) -> Self { - Cow::Borrowed(url) - } + fn from(url: &'a Url) -> Self { Cow::Borrowed(url) } } impl From for Cow<'_, Url> { - fn from(url: Url) -> Self { - Cow::Owned(url) - } + fn from(url: Url) -> Self { Cow::Owned(url) } } impl From> for Url { - fn from(url: Cow<'_, Url>) -> Self { - url.into_owned() - } + fn from(url: Cow<'_, Url>) -> Self { url.into_owned() } } impl Url { @@ -139,16 +105,16 @@ impl Url { Scheme::SearchItem => { Self { loc: Loc::with(self.loc.base(), self.loc.join(path)), scheme: Scheme::SearchItem } } - Scheme::Archive(_) => Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() }, + Scheme::Archive(_) => { + Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() } + } Scheme::Sftp(_) => Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() }, } } // FIXME: check usages #[inline] - pub fn components(&self) -> Components<'_> { - Components::new(self) - } + pub fn components(&self) -> Components<'_> { Components::new(self) } #[inline] pub fn covariant(&self, other: &Self) -> bool { @@ -156,14 +122,10 @@ impl Url { } #[inline] - pub fn display(&self) -> Display<'_> { - Display::new(self) - } + pub fn display(&self) -> Display<'_> { Display::new(self) } #[inline] - pub fn os_str(&self) -> Cow<'_, OsStr> { - self.components().os_str() - } + pub fn os_str(&self) -> Cow<'_, OsStr> { self.components().os_str() } pub fn parent_url(&self) -> Option { let parent = self.loc.parent()?; @@ -189,7 +151,10 @@ impl Url { return None; } - Some(Self { loc: self.loc.strip_prefix(&base.loc).ok()?.into(), scheme: self.scheme.clone() }) + Some(Self { + loc: self.loc.strip_prefix(&base.loc).ok()?.into(), + scheme: self.scheme.clone(), + }) } #[inline] @@ -198,19 +163,13 @@ impl Url { } #[inline] - pub fn set_name(&mut self, name: impl AsRef) { - self.loc.set_name(name); - } + pub fn set_name(&mut self, name: impl AsRef) { self.loc.set_name(name); } #[inline] - pub fn pair(&self) -> Option<(Self, UrnBuf)> { - Some((self.parent_url()?, self.loc.urn_owned())) - } + pub fn pair(&self) -> Option<(Self, UrnBuf)> { Some((self.parent_url()?, self.loc.urn_owned())) } #[inline] - pub fn hash_u64(&self) -> u64 { - foldhash::fast::FixedState::default().hash_one(self) - } + pub fn hash_u64(&self) -> u64 { foldhash::fast::FixedState::default().hash_one(self) } #[inline] pub fn rebase(&self, parent: &Path) -> Self { @@ -222,14 +181,10 @@ impl Url { impl Url { // --- Regular #[inline] - pub fn is_regular(&self) -> bool { - self.scheme == Scheme::Regular - } + pub fn is_regular(&self) -> bool { self.scheme == Scheme::Regular } #[inline] - pub fn to_regular(&self) -> Self { - Self { loc: self.loc.clone(), scheme: Scheme::Regular } - } + pub fn to_regular(&self) -> Self { Self { loc: self.loc.clone(), scheme: Scheme::Regular } } #[inline] pub fn into_regular(mut self) -> Self { @@ -239,9 +194,7 @@ impl Url { // --- Search #[inline] - pub fn is_search(&self) -> bool { - matches!(self.scheme, Scheme::Search(_)) - } + pub fn is_search(&self) -> bool { matches!(self.scheme, Scheme::Search(_)) } #[inline] pub fn to_search(&self, frag: impl AsRef) -> Self { @@ -256,15 +209,11 @@ impl Url { // --- Archive #[inline] - pub fn is_archive(&self) -> bool { - matches!(self.scheme, Scheme::Archive(_)) - } + pub fn is_archive(&self) -> bool { matches!(self.scheme, Scheme::Archive(_)) } // FIXME: remove #[inline] - pub fn into_path(self) -> PathBuf { - self.loc.into_path() - } + pub fn into_path(self) -> PathBuf { self.loc.into_path() } } impl Debug for Url { @@ -292,4 +241,4 @@ impl<'de> Deserialize<'de> for Url { let s = String::deserialize(deserializer)?; Self::try_from(s).map_err(serde::de::Error::custom) } -} +} \ No newline at end of file