mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: apply natural sort to partitions on both Linux and macOS (#2235)
This commit is contained in:
parent
456935658a
commit
abb43251fa
3 changed files with 5 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ use std::{borrow::Cow, collections::{HashMap, HashSet}, ffi::{OsStr, OsString},
|
|||
use anyhow::Result;
|
||||
use tokio::{io::{Interest, unix::AsyncFd}, time::sleep};
|
||||
use tracing::error;
|
||||
use yazi_shared::{replace_cow, replace_vec_cow};
|
||||
use yazi_shared::{natsort, replace_cow, replace_vec_cow};
|
||||
|
||||
use super::{Locked, Partition, Partitions};
|
||||
|
||||
|
|
@ -77,6 +77,7 @@ impl Partitions {
|
|||
let mut set: HashSet<&OsStr> = set.iter().map(AsRef::as_ref).collect();
|
||||
mounts.iter().filter_map(|p| p.dev_name()).for_each(|s| _ = set.remove(s));
|
||||
mounts.extend(set.into_iter().map(Partition::new));
|
||||
mounts.sort_unstable_by(|a, b| natsort(a.src.as_bytes(), b.src.as_bytes(), false));
|
||||
};
|
||||
|
||||
let labels = Self::labels()?;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use objc::{msg_send, runtime::Object, sel, sel_impl};
|
|||
use scopeguard::defer;
|
||||
use tracing::error;
|
||||
use yazi_ffi::{CFDict, CFString, DADiskCopyDescription, DADiskCreateFromBSDName, DARegisterDiskAppearedCallback, DARegisterDiskDescriptionChangedCallback, DARegisterDiskDisappearedCallback, DASessionCreate, DASessionScheduleWithRunLoop, IOIteratorNext, IOObjectRelease, IORegistryEntryCreateCFProperty, IOServiceGetMatchingServices, IOServiceMatching};
|
||||
use yazi_shared::natsort;
|
||||
|
||||
use super::{Locked, Partition, Partitions};
|
||||
|
||||
|
|
@ -145,7 +146,7 @@ impl Partitions {
|
|||
}
|
||||
}
|
||||
|
||||
names.sort_unstable();
|
||||
names.sort_unstable_by(|a, b| natsort(a.as_bytes(), b.as_bytes(), false));
|
||||
Ok(names)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ impl Partition {
|
|||
let b: &[u8] = self.fstype.as_ref().map_or(b"", |s| s.as_encoded_bytes());
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
matches!(b, b"autofs" | b"binfmt_misc" | b"bpf" | b"cgroup2" | b"configfs" | b"debugfs" | b"devpts" | b"devtmpfs" | b"fuse.gvfsd-fuse" | b"fusectl" | b"hugetlbfs" | b"mqueue" | b"proc" | b"ramfs" | b"securityfs" | b"sysfs" | b"tmpfs")
|
||||
matches!(b, b"autofs" | b"binfmt_misc" | b"bpf" | b"cgroup2" | b"configfs" | b"debugfs" | b"devpts" | b"devtmpfs" | b"fuse.gvfsd-fuse" | b"fusectl" | b"hugetlbfs" | b"mqueue" | b"proc" | b"pstore" | b"ramfs" | b"securityfs" | b"sysfs" | b"tmpfs" | b"tracefs")
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue