feat(cmds): add :move! to overwrite destination;

pull/11093/head
5-pebbles 5 months ago
parent 8b86742ff9
commit 10c025d354

@ -86,5 +86,6 @@
| `:clear-register` | Clear given register. If no argument is provided, clear all registers. |
| `:redraw` | Clear and re-render the whole UI |
| `:move` | Move the current buffer and its corresponding file to a different path |
| `:move!` | Force move the current buffer and its corresponding file to a different path, overwriting the destination. |
| `:yank-diagnostic` | Yank diagnostic(s) under primary cursor to register, or clipboard by default |
| `:read`, `:r` | Load a file into buffer |

@ -2431,6 +2431,19 @@ fn move_buffer(
move_buffer_impl(cx, args.first().unwrap(), false)
}
fn force_move_buffer(
cx: &mut compositor::Context,
args: &[Cow<str>],
event: PromptEvent,
) -> anyhow::Result<()> {
if event != PromptEvent::Validate {
return Ok(());
}
ensure!(args.len() == 1, format!(":move! takes one argument"));
move_buffer_impl(cx, args.first().unwrap(), true)
}
fn yank_diagnostic(
cx: &mut compositor::Context,
args: &[Cow<str>],
@ -3111,6 +3124,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: move_buffer,
signature: CommandSignature::positional(&[completers::filename]),
},
TypableCommand {
name: "move!",
aliases: &[],
doc: "Force move the current buffer and its corresponding file to a different path, overwriting the destination.",
fun: force_move_buffer,
signature: CommandSignature::positional(&[completers::filename]),
},
TypableCommand {
name: "yank-diagnostic",
aliases: &[],

Loading…
Cancel
Save