diff --git a/yazi-config/preset/yazi.toml b/yazi-config/preset/yazi.toml index 97a728a2..545550cd 100644 --- a/yazi-config/preset/yazi.toml +++ b/yazi-config/preset/yazi.toml @@ -180,7 +180,7 @@ delete_offset = [ 0, 5, 70, 20 ] # overwrite overwrite_title = "Are you sure?" -overwrite_content = "Overwrite existing file: {file}?" +overwrite_content = "Will overwrite existing file: {url}" overwrite_origin = "top-center" overwrite_offset = [ 0, 2, 50, 20 ] diff --git a/yazi-config/src/popup/options.rs b/yazi-config/src/popup/options.rs index 51dc2353..dbab4c67 100644 --- a/yazi-config/src/popup/options.rs +++ b/yazi-config/src/popup/options.rs @@ -1,3 +1,5 @@ +use yazi_shared::fs::Url; + use super::{Offset, Position}; use crate::{CONFIRM, INPUT, SELECT}; @@ -127,10 +129,10 @@ impl ConfirmCfg { } #[inline] - pub fn overwrite(file: &str) -> Self { + pub fn overwrite(url: &Url) -> Self { Self { title: CONFIRM.overwrite_title.to_owned(), - content: CONFIRM.overwrite_content.replace("{file}", file), + content: CONFIRM.overwrite_content.replace("{url}", &url.to_string()), position: Position::new(CONFIRM.overwrite_origin, CONFIRM.overwrite_offset), } } diff --git a/yazi-core/src/manager/commands/create.rs b/yazi-core/src/manager/commands/create.rs index 16fc114a..f13f0036 100644 --- a/yazi-core/src/manager/commands/create.rs +++ b/yazi-core/src/manager/commands/create.rs @@ -31,11 +31,11 @@ impl Manager { } let new = cwd.join(&name); - if !opt.force && maybe_exists(&new).await { - match ConfirmProxy::show(ConfirmCfg::overwrite(&new.to_string())).await { - Ok(c) if c => (), - _ => return Ok(()), - } + if !opt.force + && maybe_exists(&new).await + && !ConfirmProxy::show(ConfirmCfg::overwrite(&new)).await + { + return Ok(()); } Self::create_do(new, opt.dir || name.ends_with('/') || name.ends_with('\\')).await diff --git a/yazi-core/src/manager/commands/quit.rs b/yazi-core/src/manager/commands/quit.rs index c05a691e..7cec3022 100644 --- a/yazi-core/src/manager/commands/quit.rs +++ b/yazi-core/src/manager/commands/quit.rs @@ -52,12 +52,8 @@ impl Manager { } } - // recv(&mut result); - - if let Ok(choice) = result.await { - if choice { - emit!(Quit(opt)); - } + if result.await { + emit!(Quit(opt)); } }); } diff --git a/yazi-plugin/src/utils/layer.rs b/yazi-plugin/src/utils/layer.rs index 66945c3b..0b0f0f85 100644 --- a/yazi-plugin/src/utils/layer.rs +++ b/yazi-plugin/src/utils/layer.rs @@ -88,18 +88,13 @@ impl Utils { ya.raw_set( "confirm", - lua.create_async_function(|lua, t: Table| async move { + lua.create_async_function(|_, t: Table| async move { let result = ConfirmProxy::show(ConfirmCfg { title: t.raw_get("title")?, content: t.raw_get("content")?, position: Position::try_from(t.raw_get::<_, Table>("position")?)?.into(), }); - - if let Ok(_answer) = result.await { - true.into_lua_multi(lua) - } else { - false.into_lua_multi(lua) - } + Ok(result.await) })?, )?;