mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
dfeafa995c
commit
fcc41037ee
5 changed files with 30 additions and 34 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
|
@ -2319,11 +2319,10 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libredox"
|
name = "libredox"
|
||||||
version = "0.1.12"
|
version = "0.1.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616"
|
checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.11.0",
|
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -3321,12 +3320,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pxfm"
|
name = "pxfm"
|
||||||
version = "0.1.27"
|
version = "0.1.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7186d3822593aa4393561d186d1393b3923e9d6163d3fbfd6e825e3e6cf3e6a8"
|
checksum = "b5a041e753da8b807c9255f28de81879c78c876392ff2469cde94799b2896b9d"
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "qoi"
|
name = "qoi"
|
||||||
|
|
@ -3746,9 +3742,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "russh"
|
name = "russh"
|
||||||
version = "0.57.0"
|
version = "0.57.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "01fe22d10a0e39c1134a971d5b8db8a40357b48ef22d81fa8d6eac22202dd782"
|
checksum = "afe62631a04a1f4d71a14b99505483b95ff97c503b67d876c042fce659186956"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"bitflags 2.11.0",
|
"bitflags 2.11.0",
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ percent-encoding = "2.3.2"
|
||||||
rand = { version = "0.9.2", default-features = false, features = [ "os_rng", "small_rng", "std" ] }
|
rand = { version = "0.9.2", default-features = false, features = [ "os_rng", "small_rng", "std" ] }
|
||||||
ratatui = { version = "0.30.0", features = [ "serde", "unstable-rendered-line-info", "unstable-widget-ref" ] }
|
ratatui = { version = "0.30.0", features = [ "serde", "unstable-rendered-line-info", "unstable-widget-ref" ] }
|
||||||
regex = "1.12.3"
|
regex = "1.12.3"
|
||||||
russh = { version = "0.57.0", default-features = false, features = [ "ring", "rsa" ] }
|
russh = { version = "0.57.1", default-features = false, features = [ "ring", "rsa" ] }
|
||||||
scopeguard = "1.2.0"
|
scopeguard = "1.2.0"
|
||||||
serde = { version = "1.0.228", features = [ "derive" ] }
|
serde = { version = "1.0.228", features = [ "derive" ] }
|
||||||
serde_json = "1.0.149"
|
serde_json = "1.0.149"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ pub fn deserialize_over(input: TokenStream) -> TokenStream {
|
||||||
quote! {
|
quote! {
|
||||||
impl #ident {
|
impl #ident {
|
||||||
pub(crate) fn deserialize_over(self, input: &str) -> Result<Self, toml::de::Error> {
|
pub(crate) fn deserialize_over(self, input: &str) -> Result<Self, toml::de::Error> {
|
||||||
crate::error_with_input(self.deserialize_over_with(crate::parse_recoverable(input)?), input)
|
crate::error_with_input(self.deserialize_over_with(toml::de::DeTable::parse(input)?), input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,12 +31,15 @@ pub fn deserialize_over1(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
assignments.push(quote! {
|
assignments.push(quote! {
|
||||||
if let Some(value) = table.remove(#field_name) {
|
if let Some(value) = table.remove(#field_name) {
|
||||||
|
if !matches!(value.get_ref(), toml::de::DeValue::Table(_)) {
|
||||||
|
_ = toml::Table::deserialize(value.into_deserializer())?;
|
||||||
|
return Err(serde::de::Error::custom(format!("expected top-level `{}` to be a TOML table", #field_name)));
|
||||||
|
}
|
||||||
|
|
||||||
let span = value.span();
|
let span = value.span();
|
||||||
let table = match value.into_inner() {
|
if let toml::de::DeValue::Table(table) = value.into_inner() {
|
||||||
toml::de::DeValue::Table(table) => table,
|
self.#field_ident = self.#field_ident.deserialize_over_with(toml::Spanned::new(span, table))?;
|
||||||
_ => return Err(serde::de::Error::custom(format!("expected top-level `{}` to be a TOML table", #field_name))),
|
}
|
||||||
};
|
|
||||||
self.#field_ident = self.#field_ident.deserialize_over_with(toml::Spanned::new(span, table))?;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -52,8 +55,11 @@ pub fn deserialize_over1(input: TokenStream) -> TokenStream {
|
||||||
impl #ident {
|
impl #ident {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn deserialize_over_with<'de>(mut self, table: toml::Spanned<toml::de::DeTable<'de>>) -> Result<Self, toml::de::Error> {
|
pub(crate) fn deserialize_over_with<'de>(mut self, table: toml::Spanned<toml::de::DeTable<'de>>) -> Result<Self, toml::de::Error> {
|
||||||
|
use serde::{Deserialize, de::IntoDeserializer};
|
||||||
|
|
||||||
let mut table = table.into_inner();
|
let mut table = table.into_inner();
|
||||||
#(#assignments)*
|
#(#assignments)*
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -71,13 +77,12 @@ pub fn deserialize_over2(input: TokenStream) -> TokenStream {
|
||||||
let mut assignments = Vec::with_capacity(fields.named.len());
|
let mut assignments = Vec::with_capacity(fields.named.len());
|
||||||
|
|
||||||
for field in fields.named {
|
for field in fields.named {
|
||||||
let (ty, field_ident) = (field.ty, field.ident);
|
let field_ident = field.ident;
|
||||||
let field_name = field_ident.as_ref().unwrap().to_string();
|
let field_name = field_ident.as_ref().unwrap().to_string();
|
||||||
|
|
||||||
assignments.push(quote! {
|
assignments.push(quote! {
|
||||||
if let Some(value) = table.remove(#field_name) {
|
if let Some(value) = table.remove(#field_name) {
|
||||||
let de = serde::de::IntoDeserializer::into_deserializer(value);
|
self.#field_ident = <_>::deserialize(value.into_deserializer())?;
|
||||||
self.#field_ident = <#ty as serde::Deserialize>::deserialize(de)?;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -93,8 +98,11 @@ pub fn deserialize_over2(input: TokenStream) -> TokenStream {
|
||||||
impl #ident {
|
impl #ident {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn deserialize_over_with<'de>(mut self, table: toml::Spanned<toml::de::DeTable<'de>>) -> Result<Self, toml::de::Error> {
|
pub(crate) fn deserialize_over_with<'de>(mut self, table: toml::Spanned<toml::de::DeTable<'de>>) -> Result<Self, toml::de::Error> {
|
||||||
|
use serde::{Deserialize, de::IntoDeserializer};
|
||||||
|
|
||||||
let mut table = table.into_inner();
|
let mut table = table.into_inner();
|
||||||
#(#assignments)*
|
#(#assignments)*
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ yazi_macro::mod_flat!(icon layout pattern platform preset priority style utils y
|
||||||
|
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
use toml::{Spanned, de::DeTable};
|
|
||||||
use yazi_shared::{RoCell, SyncCell};
|
use yazi_shared::{RoCell, SyncCell};
|
||||||
use yazi_tty::TTY;
|
use yazi_tty::TTY;
|
||||||
|
|
||||||
|
|
@ -48,7 +47,7 @@ fn try_init_flavor(light: bool, merge: bool) -> anyhow::Result<()> {
|
||||||
|
|
||||||
if merge {
|
if merge {
|
||||||
let theme_str = theme::Theme::read()?;
|
let theme_str = theme::Theme::read()?;
|
||||||
let theme = parse_recoverable(&theme_str)?;
|
let theme = toml::de::DeTable::parse(&theme_str)?;
|
||||||
|
|
||||||
let flavor_str = theme::Flavor::from_theme(&theme, &theme_str)?.read(light)?;
|
let flavor_str = theme::Flavor::from_theme(&theme, &theme_str)?.read(light)?;
|
||||||
|
|
||||||
|
|
@ -82,13 +81,6 @@ fn wait_for_key(e: anyhow::Error) -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_recoverable<'a>(
|
|
||||||
input: &'a str,
|
|
||||||
) -> Result<Spanned<DeTable<'a>>, toml::de::Error> {
|
|
||||||
let (table, errors) = DeTable::parse_recoverable(input);
|
|
||||||
if let Some(err) = errors.into_iter().next() { Err(err) } else { Ok(table) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn error_with_input<T>(
|
pub(crate) fn error_with_input<T>(
|
||||||
result: Result<T, toml::de::Error>,
|
result: Result<T, toml::de::Error>,
|
||||||
input: &str,
|
input: &str,
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ function M:tidy(from, to, tmp)
|
||||||
end
|
end
|
||||||
|
|
||||||
local only = #outs == 1 and outs[1]
|
local only = #outs == 1 and outs[1]
|
||||||
if only and not only.cha.is_dir and require("archive").is_tar(outs[1].url) then
|
if only and not only.cha.is_dir and require("archive").is_tar(only.url) then
|
||||||
self:entry { args = { tostring(outs[1].url), tostring(to) } }
|
self:entry { args = { tostring(only.url), tostring(to) } }
|
||||||
fs.remove("file", outs[1].url)
|
fs.remove("file", only.url)
|
||||||
fs.remove("dir", tmp)
|
fs.remove("dir", tmp)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -93,8 +93,8 @@ function M:tidy(from, to, tmp)
|
||||||
fail("Failed to determine a target for '%s'", from)
|
fail("Failed to determine a target for '%s'", from)
|
||||||
end
|
end
|
||||||
|
|
||||||
if only and not fs.rename(outs[1].url, target) then
|
if only and not fs.rename(only.url, target) then
|
||||||
fail('Failed to move "%s" to "%s"', outs[1].url, target)
|
fail('Failed to move "%s" to "%s"', only.url, target)
|
||||||
elseif not only and not fs.rename(tmp, target) then
|
elseif not only and not fs.rename(tmp, target) then
|
||||||
fail('Failed to move "%s" to "%s"', tmp, target)
|
fail('Failed to move "%s" to "%s"', tmp, target)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue