on master help sign in
Implement the wa! command (#7577)
commit828c7432e363c46cd9202cdb973a67f0421d2c0f authorRyan Fowler <ryan.fowler19@gmail.com> dateSun 9 Jul 2023, 07:38 (3 years ago) parent1698992
2 files changed+20
book/src/generated/typable-cmd.md+1 helix-term/src/commands/typed.rs+19
book/src/generated/typable-cmd.md+1
@@ -24,6 +24,7 @@
2424| `:write-quit`, `:wq`, `:x` | Write changes to disk and close the current view. Accepts an optional path (:wq some/path.txt) |
2525| `:write-quit!`, `:wq!`, `:x!` | Write changes to disk and close the current view forcefully. Accepts an optional path (:wq! some/path.txt) |
2626| `:write-all`, `:wa` | Write changes from all buffers to disk. |
27+| `:write-all!`, `:wa!` | Forcefully write changes from all buffers to disk creating necessary subdirectories. |
2728| `:write-quit-all`, `:wqa`, `:xa` | Write changes from all buffers to disk and close all views. |
2829| `:write-quit-all!`, `:wqa!`, `:xa!` | Write changes from all buffers to disk and close all views forcefully (ignoring unsaved changes). |
2930| `:quit-all`, `:qa` | Close all views. |
helix-term/src/commands/typed.rs+19
@@ -739,6 +739,18 @@ fn write_all(
739739 write_all_impl(cx, false, true)
740740}
741741
742+fn force_write_all(
743+ cx: &mut compositor::Context,
744+ _args: &[Cow<str>],
745+ event: PromptEvent,
746+) -> anyhow::Result<()> {
747+ if event != PromptEvent::Validate {
748+ return Ok(());
749+ }
750+
751+ write_all_impl(cx, true, true)
752+}
753+
742754fn write_all_quit(
743755 cx: &mut compositor::Context,
744756 _args: &[Cow<str>],
@@ -2444,6 +2456,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
24442456 fun: write_all,
24452457 signature: CommandSignature::none(),
24462458 },
2459+ TypableCommand {
2460+ name: "write-all!",
2461+ aliases: &["wa!"],
2462+ doc: "Forcefully write changes from all buffers to disk creating necessary subdirectories.",
2463+ fun: force_write_all,
2464+ signature: CommandSignature::none(),
2465+ },
24472466 TypableCommand {
24482467 name: "write-quit-all",
24492468 aliases: &["wqa", "xa"],