mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-24 16:21:04 +00:00
feat: add prepend_rules and append_rules for [icon] (#670)
This commit is contained in:
parent
8bf0d6428f
commit
b027487d12
2 changed files with 10 additions and 21 deletions
|
|
@ -52,24 +52,6 @@ impl<'de> Deserialize<'de> for Keymap {
|
|||
#[rustfmt::skip]
|
||||
Preset::mix(&mut shadow.completion.keymap, shadow.completion.prepend_keymap, shadow.completion.append_keymap);
|
||||
|
||||
// TODO: remove this when v0.2.3 is released --
|
||||
if !shadow.input.keymap.iter().any(|c| c.on() == "<Backspace>") {
|
||||
println!(
|
||||
"WARNING: Default keybinding for `<Backspace>` is missing, please add a `{}` to the `[input]` section of `keymap.toml`.
|
||||
In Yazi v0.2.0, `<Backspace>` previously hardcoded within the input component has been moved to `keymap.toml` to allow users to customize it.",
|
||||
r#"{ on = [ "<Backspace>" ], exec = "backspace" }"#
|
||||
);
|
||||
}
|
||||
// TODO: -- remove this when v0.2.3 is released
|
||||
|
||||
// TODO: remove this when v0.2.3 is released --
|
||||
if shadow.manager.keymap.iter().any(|c| c.exec().contains("--empty=name")) {
|
||||
println!(
|
||||
"WARNING: `rename --empty=name` is deprecated in Yazi v0.2.2, please use `rename --empty=stem` instead.",
|
||||
);
|
||||
}
|
||||
// TODO: -- remove this when v0.2.3 is released
|
||||
|
||||
Ok(Self {
|
||||
manager: shadow.manager.keymap,
|
||||
tasks: shadow.tasks.keymap,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
use super::Style;
|
||||
use crate::{theme::{Color, StyleShadow}, Pattern};
|
||||
use crate::{preset::Preset, theme::{Color, StyleShadow}, Pattern};
|
||||
|
||||
pub struct Icon {
|
||||
pub name: Pattern,
|
||||
|
|
@ -16,7 +16,11 @@ impl Icon {
|
|||
{
|
||||
#[derive(Deserialize)]
|
||||
struct IconOuter {
|
||||
rules: Vec<IconRule>,
|
||||
rules: Vec<IconRule>,
|
||||
#[serde(default)]
|
||||
prepend_rules: Vec<IconRule>,
|
||||
#[serde(default)]
|
||||
append_rules: Vec<IconRule>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct IconRule {
|
||||
|
|
@ -26,8 +30,11 @@ impl Icon {
|
|||
fg: Option<Color>,
|
||||
}
|
||||
|
||||
let mut outer = IconOuter::deserialize(deserializer)?;
|
||||
Preset::mix(&mut outer.rules, outer.prepend_rules, outer.append_rules);
|
||||
|
||||
Ok(
|
||||
IconOuter::deserialize(deserializer)?
|
||||
outer
|
||||
.rules
|
||||
.into_iter()
|
||||
.map(|r| Icon {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue