@@ -382,6 +382,36 @@ fn force_write(
382 write_impl(cx, args.first(), true)
382 write_impl(cx, args.first(), true)
385+fn write_buffer_close(
386+ cx: &mut compositor::Context,
389+) -> anyhow::Result<()> {
390+ if event != PromptEvent::Validate {
394+ write_impl(cx, args.first(), false)?;
396+ let document_ids = buffer_gather_paths_impl(cx.editor, args);
397+ buffer_close_by_ids_impl(cx, &document_ids, false)
400+fn force_write_buffer_close(
401+ cx: &mut compositor::Context,
404+) -> anyhow::Result<()> {
405+ if event != PromptEvent::Validate {
409+ write_impl(cx, args.first(), true)?;
411+ let document_ids = buffer_gather_paths_impl(cx.editor, args);
412+ buffer_close_by_ids_impl(cx, &document_ids, false)
385fn new_file(
415fn new_file(
386 cx: &mut compositor::Context,
416 cx: &mut compositor::Context,
387 _args: &[Cow<str>],
417 _args: &[Cow<str>],
@@ -2287,10 +2317,24 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2287 TypableCommand {
2317 TypableCommand {
2288 name: "write!",
2318 name: "write!",
2289 aliases: &["w!"],
2319 aliases: &["w!"],
2290− doc: "Force write changes to disk creating necessary subdirectories. Accepts an optional path (:write some/path.txt)",
2320+ doc: "Force write changes to disk creating necessary subdirectories. Accepts an optional path (:write! some/path.txt)",
2291 fun: force_write,
2321 fun: force_write,
2292 signature: CommandSignature::positional(&[completers::filename]),
2322 signature: CommandSignature::positional(&[completers::filename]),
2325+ name: "write-buffer-close",
2327+ doc: "Write changes to disk and closes the buffer. Accepts an optional path (:write-buffer-close some/path.txt)",
2328+ fun: write_buffer_close,
2329+ signature: CommandSignature::positional(&[completers::filename]),
2332+ name: "write-buffer-close!",
2333+ aliases: &["wbc!"],
2334+ doc: "Force write changes to disk creating necessary subdirectories and closes the buffer. Accepts an optional path (:write-buffer-close! some/path.txt)",
2335+ fun: force_write_buffer_close,
2336+ signature: CommandSignature::positional(&[completers::filename]),
2294 TypableCommand {
2338 TypableCommand {
2295 name: "new",
2339 name: "new",
2296 aliases: &["n"],
2340 aliases: &["n"],