mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: Enable the ability to sort the which key
formatted properly
This commit is contained in:
parent
f6b4c923b4
commit
79f63a9ae2
7 changed files with 64 additions and 73 deletions
|
|
@ -17,8 +17,8 @@ mod priority;
|
|||
mod tasks;
|
||||
pub mod theme;
|
||||
mod validation;
|
||||
mod xdg;
|
||||
pub mod which;
|
||||
mod xdg;
|
||||
|
||||
pub use layout::*;
|
||||
pub(crate) use pattern::*;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl FromStr for SortBy {
|
|||
"none" => Self::None,
|
||||
"key" => Self::Key,
|
||||
"desc" => Self::Desc,
|
||||
_ => bail!("Invalid sort option: {s}")
|
||||
_ => bail!("Invalid sort option: {s}"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -28,9 +28,7 @@ impl FromStr for SortBy {
|
|||
impl TryFrom<String> for SortBy {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: String) -> Result<Self, Self::Error> {
|
||||
Self::from_str(&value)
|
||||
}
|
||||
fn try_from(value: String) -> Result<Self, Self::Error> { Self::from_str(&value) }
|
||||
}
|
||||
|
||||
impl ToString for SortBy {
|
||||
|
|
@ -39,6 +37,7 @@ impl ToString for SortBy {
|
|||
Self::None => "none",
|
||||
Self::Key => "key",
|
||||
Self::Desc => "desc",
|
||||
}.to_string()
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ impl Default for Config {
|
|||
}
|
||||
|
||||
impl Config {
|
||||
#[allow(unused)]
|
||||
pub(super) fn patch<F: FnOnce(&mut Self)>(&mut self, f: F) -> bool {
|
||||
let old = self.clone();
|
||||
f(self);
|
||||
*self != old
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn sorter(&self) -> WhichSorter {
|
||||
|
|
@ -38,4 +32,3 @@ impl Config {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
mod commands;
|
||||
mod which;
|
||||
mod config;
|
||||
mod sorter;
|
||||
mod which;
|
||||
|
||||
pub use which::*;
|
||||
pub use config::*;
|
||||
pub use sorter::*;
|
||||
pub use which::*;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_config::{which::SortBy, keymap::ControlCow};
|
||||
use yazi_config::{keymap::ControlCow, which::SortBy};
|
||||
use yazi_shared::natsort;
|
||||
|
||||
#[derive(Clone, Copy, Default, PartialEq)]
|
||||
|
|
@ -30,10 +30,9 @@ impl WhichSorter {
|
|||
// what if description isn't present (need to check if it's mandatory or not)
|
||||
// in case if it is not present, should I just panic ?
|
||||
by_alphabetical(a.desc.as_ref().unwrap(), b.desc.as_ref().unwrap())
|
||||
})
|
||||
}),
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue