on master help sign in
update write-quit to wait for saves
69c9e44Skyler Hawthorne
helix-term/src/commands/typed.rs+6−2
@@ -518,8 +518,12 @@ fn write_quit(
518 }
518 }
519
519
520 write_impl(cx, args.first(), false)?;
520 write_impl(cx, args.first(), false)?;
521− // TODO: change to use document close
521+ let doc = doc_mut!(cx.editor);
522− helix_lsp::block_on(cx.jobs.finish())?;
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+
523 quit(cx, &[], event)
527 quit(cx, &[], event)
524}
528}
525
529
helix-term/tests/test/commands.rs+6−1
@@ -8,7 +8,7 @@ use helix_term::application::Application;
8
8
9use super::*;
9use super::*;
10
10
11−#[tokio::test]
11+#[tokio::test(flavor = "multi_thread")]
12async fn test_write_quit_fail() -> anyhow::Result<()> {
12async fn test_write_quit_fail() -> anyhow::Result<()> {
13 let file = helpers::new_readonly_tempfile()?;
13 let file = helpers::new_readonly_tempfile()?;
14
14
@@ -16,6 +16,11 @@ async fn test_write_quit_fail() -> anyhow::Result<()> {
16 &mut helpers::app_with_file(file.path())?,
16 &mut helpers::app_with_file(file.path())?,
17 Some("ihello<esc>:wq<ret>"),
17 Some("ihello<esc>:wq<ret>"),
18 Some(&|app| {
18 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));
19 assert_eq!(&Severity::Error, app.editor.get_status().unwrap().1);
24 assert_eq!(&Severity::Error, app.editor.get_status().unwrap().1);
20 }),
25 }),
21 false,
26 false,