on master help sign in
Implement the wa! command (#7577)
828c743Ryan Fowler
book/src/generated/typable-cmd.md+1
@@ -24,6 +24,7 @@
24| `:write-quit`, `:wq`, `:x` | Write changes to disk and close the current view. Accepts an optional path (:wq some/path.txt) |
24| `:write-quit`, `:wq`, `:x` | Write changes to disk and close the current view. Accepts an optional path (:wq some/path.txt) |
25| `:write-quit!`, `:wq!`, `:x!` | Write changes to disk and close the current view forcefully. Accepts an optional path (:wq! some/path.txt) |
25| `:write-quit!`, `:wq!`, `:x!` | Write changes to disk and close the current view forcefully. Accepts an optional path (:wq! some/path.txt) |
26| `:write-all`, `:wa` | Write changes from all buffers to disk. |
26| `: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. |
27| `:write-quit-all`, `:wqa`, `:xa` | Write changes from all buffers to disk and close all views. |
28| `:write-quit-all`, `:wqa`, `:xa` | Write changes from all buffers to disk and close all views. |
28| `:write-quit-all!`, `:wqa!`, `:xa!` | Write changes from all buffers to disk and close all views forcefully (ignoring unsaved changes). |
29| `:write-quit-all!`, `:wqa!`, `:xa!` | Write changes from all buffers to disk and close all views forcefully (ignoring unsaved changes). |
29| `:quit-all`, `:qa` | Close all views. |
30| `:quit-all`, `:qa` | Close all views. |
helix-term/src/commands/typed.rs+19
@@ -739,6 +739,18 @@ fn write_all(
739 write_all_impl(cx, false, true)
739 write_all_impl(cx, false, true)
740}
740}
741
741
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+
742fn write_all_quit(
754fn write_all_quit(
743 cx: &mut compositor::Context,
755 cx: &mut compositor::Context,
744 _args: &[Cow<str>],
756 _args: &[Cow<str>],
@@ -2444,6 +2456,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2444 fun: write_all,
2456 fun: write_all,
2445 signature: CommandSignature::none(),
2457 signature: CommandSignature::none(),
2446 },
2458 },
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+ },
2447 TypableCommand {
2466 TypableCommand {
2448 name: "write-quit-all",
2467 name: "write-quit-all",
2449 aliases: &["wqa", "xa"],
2468 aliases: &["wqa", "xa"],