From 629df6124df4c136a4b4de6e1aeb887bbbaaddbe Mon Sep 17 00:00:00 2001 From: Shafkath Shuhan Date: Wed, 23 Jun 2021 22:30:21 -0400 Subject: Blocking :wq --- helix-term/src/commands.rs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d176fbca..bb99f2b5 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1061,7 +1061,7 @@ mod cmd { view: &View, doc: &mut Document, path: Option

, - ) -> Result<(), anyhow::Error> { + ) -> Result>, anyhow::Error> { use anyhow::anyhow; if let Some(path) = path { @@ -1079,8 +1079,7 @@ mod cmd { if autofmt { doc.format(view.id); // TODO: merge into save } - helix_lsp::block_on(tokio::spawn(doc.save())); - Ok(()) + Ok(tokio::spawn(doc.save())) } fn write(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) { @@ -1203,15 +1202,35 @@ mod cmd { fn write_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) { let (view, doc) = current!(cx.editor); - if let Err(e) = write_impl(view, doc, args.first()) { - cx.editor.set_error(e.to_string()); - return; + match write_impl(view, doc, args.first()) { + Ok(handle) => { + if let Err(e) = helix_lsp::block_on(handle) { + cx.editor.set_error(e.to_string()); + return; + } + } + Err(e) => { + cx.editor.set_error(e.to_string()); + return; + } }; quit(cx, &[], event) } fn force_write_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) { - write(cx, args, event); + let (view, doc) = current!(cx.editor); + match write_impl(view, doc, args.first()) { + Ok(handle) => { + if let Err(e) = helix_lsp::block_on(handle) { + cx.editor.set_error(e.to_string()); + return; + } + } + Err(e) => { + cx.editor.set_error(e.to_string()); + return; + } + }; force_quit(cx, &[], event); } -- cgit v1.2.3-70-g09d2