From e645804b0a8e42c9fb9ef8259a9b2ad47a57a6e6 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Sun, 16 Oct 2022 21:40:40 -0400 Subject: Editor::flush_writes returns an error --- helix-view/src/editor.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'helix-view/src') 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(()) } } -- cgit v1.2.3-70-g09d2