diff --git a/yazi-actor/src/mgr/bulk_create.rs b/yazi-actor/src/mgr/bulk_create.rs index ac4f991a..920c4e4a 100644 --- a/yazi-actor/src/mgr/bulk_create.rs +++ b/yazi-actor/src/mgr/bulk_create.rs @@ -1,4 +1,4 @@ -use std::{io::{Read, Write}, path::Path}; +use std::{io::{Read, Write}, path::Path, sync::Arc}; use anyhow::{Result, anyhow, bail}; use scopeguard::defer; @@ -6,8 +6,9 @@ use yazi_binding::Permit; use yazi_config::{YAZI, opener::OpenerRule}; use yazi_fs::{File, FilesOp, Splatter, provider::{FileBuilder, Provider, local::{Gate, Local}}}; use yazi_macro::{ok_or_not_found, succ}; -use yazi_parser::VoidOpt; -use yazi_proxy::{AppProxy, MgrProxy, NotifyProxy, TasksProxy}; +use yazi_parser::VoidForm; +use yazi_proxy::{MgrProxy, TasksProxy}; +use yazi_scheduler::{AppProxy, NotifyProxy}; use yazi_shared::{data::Data, terminal_clear, url::{AsUrl, UrlBuf, UrlCow, UrlLike}}; use yazi_term::YIELD_TO_SUBPROCESS; use yazi_tty::TTY; @@ -17,11 +18,11 @@ use yazi_watcher::WATCHER; use crate::{Actor, Ctx}; pub struct BulkCreate; impl Actor for BulkCreate { - type Options = VoidOpt; + type Form = VoidForm; const NAME: &str = "bulk_create"; - fn act(cx: &mut Ctx, _: Self::Options) -> Result { + fn act(cx: &mut Ctx, _: Self::Form) -> Result { let Some(opener) = Self::opener() else { succ!(NotifyProxy::push_warn("Bulk create", "No text opener found")); }; @@ -97,8 +98,11 @@ impl BulkCreate { Ok(()) } - fn opener() -> Option<&'static OpenerRule> { - YAZI.opener.block(YAZI.open.all(Path::new("bulk-rename.txt"), "text/plain")) + fn opener() -> Option> { + YAZI + .open + .match_dummy(Path::new("bulk-create.txt"), "text/plain") + .and_then(|r| YAZI.opener.block(&r)) } async fn create_one(new: &UrlBuf, dir: bool) -> Result { diff --git a/yazi-config/preset/keymap-default.toml b/yazi-config/preset/keymap-default.toml index 0ed8e4f0..ca8ac7aa 100644 --- a/yazi-config/preset/keymap-default.toml +++ b/yazi-config/preset/keymap-default.toml @@ -76,7 +76,7 @@ keymap = [ { on = "d", run = "remove", desc = "Trash selected files" }, { on = "D", run = "remove --permanently", desc = "Permanently delete selected files" }, { on = "a", run = "create", desc = "Create a file (ends with / for directories)" }, - { on = "A", run = "bulk_create", desc = "Create files from a list with your editor"}, + { on = "A", run = "bulk_create", desc = "Bulk create files" }, { on = "r", run = "rename --cursor=before_ext", desc = "Rename selected file(s)" }, { on = ";", run = "shell --interactive", desc = "Run a shell command" }, { on = ":", run = "shell --block --interactive", desc = "Run a shell command (block until finishes)" }, diff --git a/yazi-parser/src/spark/spark.rs b/yazi-parser/src/spark/spark.rs index 6b82c4db..a6cbc703 100644 --- a/yazi-parser/src/spark/spark.rs +++ b/yazi-parser/src/spark/spark.rs @@ -28,6 +28,7 @@ pub enum Spark<'a> { // Mgr Arrow(crate::ArrowForm), Back(crate::VoidForm), + BulkCreate(crate::VoidForm), BulkExit(crate::mgr::BulkExitForm), BulkRename(crate::VoidForm), Cd(crate::mgr::CdForm), @@ -215,6 +216,7 @@ impl<'a> IntoLua for Spark<'a> { // Mgr Self::Arrow(b) => b.into_lua(lua), Self::Back(b) => b.into_lua(lua), + Self::BulkCreate(b) => b.into_lua(lua), Self::BulkExit(b) => b.into_lua(lua), Self::BulkRename(b) => b.into_lua(lua), Self::Cd(b) => b.into_lua(lua),