diff options
author | Skyler Hawthorne | 2022-10-17 01:40:40 +0000 |
---|---|---|
committer | Skyler Hawthorne | 2022-10-19 02:31:39 +0000 |
commit | e645804b0a8e42c9fb9ef8259a9b2ad47a57a6e6 (patch) | |
tree | 37aa2579e0dd2b91f4c506882874730d3f41161c /helix-view | |
parent | 52ba550098745b463f59211a0172c334daef350b (diff) |
Editor::flush_writes returns an error
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/editor.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index dc1a800e..9f74c5ec 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -29,7 +29,7 @@ use tokio::{ time::{sleep, Duration, Instant, Sleep}, }; -use anyhow::{anyhow, Error}; +use anyhow::{anyhow, bail, Error}; pub use helix_core::diagnostic::Severity; pub use helix_core::register::Registers; @@ -1355,22 +1355,24 @@ impl Editor { } } - pub async fn flush_writes(&mut self) { + pub async fn flush_writes(&mut self) -> anyhow::Result<()> { while self.write_count > 0 { if let Some(save_event) = self.save_queue.next().await { - match &save_event { - Ok(event) => { - let doc = doc_mut!(self, &event.doc_id); - doc.set_last_saved_revision(event.revision); - } + self.write_count -= 1; + + let save_event = match save_event { + Ok(event) => event, Err(err) => { - log::error!("error saving document: {}", err); + self.set_error(err.to_string()); + bail!(err); } }; - // TODO: if is_err: break? - self.write_count -= 1; + let doc = doc_mut!(self, &save_event.doc_id); + doc.set_last_saved_revision(save_event.revision); } } + + Ok(()) } } |