diff options
author | Shafkath Shuhan | 2021-06-24 02:30:21 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-24 13:38:38 +0000 |
commit | 629df6124df4c136a4b4de6e1aeb887bbbaaddbe (patch) | |
tree | ee47381bfe1859d2fe62880671f1b70713254f8c /helix-term/src | |
parent | 8935e7a8791eea391a1de41a78278b4bf5dd241d (diff) |
Blocking :wq
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 33 |
1 files changed, 26 insertions, 7 deletions
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<P>, - ) -> Result<(), anyhow::Error> { + ) -> Result<tokio::task::JoinHandle<Result<(), anyhow::Error>>, 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); } |