on master help sign in
update write-quit to wait for saves
commit69c9e44ef205a81c112dfb14d5f2e67e5ce9c300 authorSkyler Hawthorne <skyler@dead10ck.com> dateTue 10 May 2022, 23:41 (4 years ago) parente1f7bdb
2 files changed+12−3
helix-term/src/commands/typed.rs+6−2 helix-term/tests/test/commands.rs+6−1
helix-term/src/commands/typed.rs+6−2
@@ -518,8 +518,12 @@ fn write_quit(
518518 }
519519
520520 write_impl(cx, args.first(), false)?;
521− // TODO: change to use document close
522− helix_lsp::block_on(cx.jobs.finish())?;
521+ let doc = doc_mut!(cx.editor);
522+
523+ tokio::task::block_in_place(|| helix_lsp::block_on(doc.try_flush_saves()))
524+ .map(|result| result.map(|_| ()))
525+ .unwrap_or(Ok(()))?;
526+
523527 quit(cx, &[], event)
524528}
525529
helix-term/tests/test/commands.rs+6−1
@@ -8,7 +8,7 @@ use helix_term::application::Application;
88
99use super::*;
1010
11−#[tokio::test]
11+#[tokio::test(flavor = "multi_thread")]
1212async fn test_write_quit_fail() -> anyhow::Result<()> {
1313 let file = helpers::new_readonly_tempfile()?;
1414
@@ -16,6 +16,11 @@ async fn test_write_quit_fail() -> anyhow::Result<()> {
1616 &mut helpers::app_with_file(file.path())?,
1717 Some("ihello<esc>:wq<ret>"),
1818 Some(&|app| {
19+ let mut docs: Vec<_> = app.editor.documents().collect();
20+ assert_eq!(1, docs.len());
21+
22+ let doc = docs.pop().unwrap();
23+ assert_eq!(Some(file.path()), doc.path().map(PathBuf::as_path));
1924 assert_eq!(&Severity::Error, app.editor.get_status().unwrap().1);
2025 }),
2126 false,