@@ -1061,7 +1061,7 @@ mod cmd {
10611061 view: &View,
10621062 doc: &mut Document,
10631063 path: Option<P>,
1064− ) -> Result<(), anyhow::Error> {
1064+ ) -> Result<tokio::task::JoinHandle<Result<(), anyhow::Error>>, anyhow::Error> {
10651065 use anyhow::anyhow;
10661066
10671067 if let Some(path) = path {
@@ -1079,8 +1079,7 @@ mod cmd {
10791079 if autofmt {
10801080 doc.format(view.id); // TODO: merge into save
10811081 }
1082− helix_lsp::block_on(tokio::spawn(doc.save()));
1083− Ok(())
1082+ Ok(tokio::spawn(doc.save()))
10841083 }
10851084
10861085 fn write(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
@@ -1203,15 +1202,35 @@ mod cmd {
12031202
12041203 fn write_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
12051204 let (view, doc) = current!(cx.editor);
1206− if let Err(e) = write_impl(view, doc, args.first()) {
1207− cx.editor.set_error(e.to_string());
1208− return;
1205+ match write_impl(view, doc, args.first()) {
1206+ Ok(handle) => {
1207+ if let Err(e) = helix_lsp::block_on(handle) {
1208+ cx.editor.set_error(e.to_string());
1209+ return;
1210+ }
1211+ }
1212+ Err(e) => {
1213+ cx.editor.set_error(e.to_string());
1214+ return;
1215+ }
12091216 };
12101217 quit(cx, &[], event)
12111218 }
12121219
12131220 fn force_write_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1214− write(cx, args, event);
1221+ let (view, doc) = current!(cx.editor);
1222+ match write_impl(view, doc, args.first()) {
1223+ Ok(handle) => {
1224+ if let Err(e) = helix_lsp::block_on(handle) {
1225+ cx.editor.set_error(e.to_string());
1226+ return;
1227+ }
1228+ }
1229+ Err(e) => {
1230+ cx.editor.set_error(e.to_string());
1231+ return;
1232+ }
1233+ };
12151234 force_quit(cx, &[], event);
12161235 }
12171236