update write-quit to wait for saves

This commit is contained in:
Skyler Hawthorne 2022-05-10 23:41:44 -04:00
parent e1f7bdb1d2
commit 69c9e44ef2
2 changed files with 12 additions and 3 deletions

View file

@ -518,8 +518,12 @@ fn write_quit(
}
write_impl(cx, args.first(), false)?;
// TODO: change to use document close
helix_lsp::block_on(cx.jobs.finish())?;
let doc = doc_mut!(cx.editor);
tokio::task::block_in_place(|| helix_lsp::block_on(doc.try_flush_saves()))
.map(|result| result.map(|_| ()))
.unwrap_or(Ok(()))?;
quit(cx, &[], event)
}

View file

@ -8,7 +8,7 @@ use helix_term::application::Application;
use super::*;
#[tokio::test]
#[tokio::test(flavor = "multi_thread")]
async fn test_write_quit_fail() -> anyhow::Result<()> {
let file = helpers::new_readonly_tempfile()?;
@ -16,6 +16,11 @@ async fn test_write_quit_fail() -> anyhow::Result<()> {
&mut helpers::app_with_file(file.path())?,
Some("ihello<esc>:wq<ret>"),
Some(&|app| {
let mut docs: Vec<_> = app.editor.documents().collect();
assert_eq!(1, docs.len());
let doc = docs.pop().unwrap();
assert_eq!(Some(file.path()), doc.path().map(PathBuf::as_path));
assert_eq!(&Severity::Error, app.editor.get_status().unwrap().1);
}),
false,