aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-05-11 03:41:44 +0000
committerSkyler Hawthorne2022-10-19 02:31:38 +0000
commit69c9e44ef205a81c112dfb14d5f2e67e5ce9c300 (patch)
treee51a3b064b391cf7c28bc1aa4f111d07b6bba3fc
parente1f7bdb1d2ef68c0de38e768080291901ff4662e (diff)
update write-quit to wait for saves
-rw-r--r--helix-term/src/commands/typed.rs8
-rw-r--r--helix-term/tests/test/commands.rs7
2 files changed, 12 insertions, 3 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index efe693b9..bc254146 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -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)
}
diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs
index 1f1bd6a9..b7c0f7cc 100644
--- a/helix-term/tests/test/commands.rs
+++ b/helix-term/tests/test/commands.rs
@@ -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,