diff --git a/Cargo.lock b/Cargo.lock index 67d864c5..8bb8f191 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1042,9 +1042,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc37f9a2bfe731e69f1e08d29d91d30604b9ce24bcb2880a961e82d89c6ed89" +checksum = "4ae047235e33e2829703574b54fdec96bfbad892062d97fed2f76022287de61b" dependencies = [ "color_quant", "weezl", diff --git a/yazi-adapter/src/brand.rs b/yazi-adapter/src/brand.rs index c9cebc75..b61fc187 100644 --- a/yazi-adapter/src/brand.rs +++ b/yazi-adapter/src/brand.rs @@ -35,6 +35,7 @@ impl Brand { ("WezTerm", Self::WezTerm), ("foot", Self::Foot), ("ghostty", Self::Ghostty), + ("Warp", Self::Warp), ("tmux ", Self::Tmux), ("libvterm", Self::VTerm), ("Bobcat", Self::Bobcat), diff --git a/yazi-fs/src/file.rs b/yazi-fs/src/file.rs index cdd3bb7b..480e66b6 100644 --- a/yazi-fs/src/file.rs +++ b/yazi-fs/src/file.rs @@ -44,17 +44,7 @@ impl File { } #[inline] - pub fn hash_u64(&self) -> u64 { - let mut h = foldhash::fast::FixedState::default().build_hasher(); - self.url.hash(&mut h); - h.write_u8(0); - self.cha.len.hash(&mut h); - h.write_u8(0); - self.cha.mtime.hash(&mut h); - h.write_u8(0); - self.cha.btime.hash(&mut h); - h.finish() - } + pub fn hash_u64(&self) -> u64 { foldhash::fast::FixedState::default().hash_one(self) } #[inline] pub fn rebase(&self, parent: &Url) -> Self { @@ -79,3 +69,12 @@ impl File { #[inline] pub fn stem(&self) -> Option<&OsStr> { self.url.file_stem() } } + +impl Hash for File { + fn hash(&self, state: &mut H) { + self.url.hash(state); + self.cha.len.hash(state); + self.cha.btime.hash(state); + self.cha.mtime.hash(state); + } +} diff --git a/yazi-plugin/preset/plugins/extract.lua b/yazi-plugin/preset/plugins/extract.lua index e59b1994..a4d2d717 100644 --- a/yazi-plugin/preset/plugins/extract.lua +++ b/yazi-plugin/preset/plugins/extract.lua @@ -27,9 +27,9 @@ function M:entry(job) end local value, event = ya.input { + pos = { "center", w = 50 }, title = string.format('Password for "%s":', from.name), obscure = true, - position = { "center", w = 50 }, } if event == 1 then pwd = value diff --git a/yazi-plugin/src/lib.rs b/yazi-plugin/src/lib.rs index 5f648cbb..3999b243 100644 --- a/yazi-plugin/src/lib.rs +++ b/yazi-plugin/src/lib.rs @@ -4,7 +4,7 @@ mod macros; yazi_macro::mod_pub!(bindings config elements external file fs isolate loader process pubsub utils); -yazi_macro::mod_flat!(clipboard composer lua runtime); +yazi_macro::mod_flat!(clipboard composer lua runtime twox); pub fn init() -> anyhow::Result<()> { CLIPBOARD.with(<_>::default); diff --git a/yazi-plugin/src/twox.rs b/yazi-plugin/src/twox.rs new file mode 100644 index 00000000..5da847fa --- /dev/null +++ b/yazi-plugin/src/twox.rs @@ -0,0 +1,17 @@ +use std::hash::Hasher; + +pub struct Twox128(twox_hash::XxHash3_128); + +impl Default for Twox128 { + fn default() -> Self { Self(twox_hash::XxHash3_128::new()) } +} + +impl Twox128 { + pub fn finish_128(self) -> u128 { self.0.finish_128() } +} + +impl Hasher for Twox128 { + fn write(&mut self, bytes: &[u8]) { self.0.write(bytes) } + + fn finish(&self) -> u64 { unreachable!() } +} diff --git a/yazi-plugin/src/utils/cache.rs b/yazi-plugin/src/utils/cache.rs index b5edc9b6..9668db42 100644 --- a/yazi-plugin/src/utils/cache.rs +++ b/yazi-plugin/src/utils/cache.rs @@ -1,10 +1,11 @@ +use std::hash::Hash; + use mlua::{Function, Lua, Table}; -use twox_hash::XxHash3_128; use yazi_binding::Url; use yazi_config::YAZI; use super::Utils; -use crate::file::FileRef; +use crate::{Twox128, file::FileRef}; impl Utils { pub(super) fn file_cache(lua: &Lua) -> mlua::Result { @@ -15,9 +16,9 @@ impl Utils { } let hex = { - let mut h = XxHash3_128::new(); - h.write(file.url.as_os_str().as_encoded_bytes()); - h.write(format!("//{:?}//{}", file.cha.mtime, t.raw_get("skip").unwrap_or(0)).as_bytes()); + let mut h = Twox128::default(); + file.hash(&mut h); + t.raw_get("skip").unwrap_or(0usize).hash(&mut h); format!("{:x}", h.finish_128()) };