From f82a551b98cec165ac91aae15ba656a811229fde Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Tue, 30 Aug 2022 23:08:15 -0400 Subject: Rename doc save event names to past tense --- helix-term/src/application.rs | 6 +++--- helix-term/src/job.rs | 1 + helix-view/src/document.rs | 24 ++++++++++++------------ helix-view/src/editor.rs | 6 +++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 70eae18a..a06460de 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -9,7 +9,7 @@ use helix_core::{ use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap}; use helix_view::{ align_view, - document::DocumentSaveEventResult, + document::DocumentSavedEventResult, editor::{ConfigEvent, EditorEvent}, theme, tree::Layout, @@ -431,7 +431,7 @@ impl Application { } } - pub fn handle_document_write(&mut self, doc_save_event: DocumentSaveEventResult) { + pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) { if let Err(err) = doc_save_event { self.editor.set_error(err.to_string()); return; @@ -485,7 +485,7 @@ impl Application { log::debug!("received editor event: {:?}", event); match event { - EditorEvent::DocumentSave(event) => { + EditorEvent::DocumentSaved(event) => { self.handle_document_write(event); self.render(); } diff --git a/helix-term/src/job.rs b/helix-term/src/job.rs index a997653d..3c9e4511 100644 --- a/helix-term/src/job.rs +++ b/helix-term/src/job.rs @@ -107,6 +107,7 @@ impl Jobs { ) -> anyhow::Result<()> { log::debug!("waiting on jobs..."); let mut wait_futures = std::mem::take(&mut self.wait_futures); + while let (Some(job), tail) = wait_futures.into_future().await { match job { Ok(callback) => { diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 86a1d6d2..91d5f8aa 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -89,14 +89,14 @@ impl Serialize for Mode { /// A snapshot of the text of a document that we want to write out to disk #[derive(Debug, Clone)] -pub struct DocumentSaveEvent { +pub struct DocumentSavedEvent { pub revision: usize, pub doc_id: DocumentId, pub path: PathBuf, } -pub type DocumentSaveEventResult = Result; -pub type DocumentSaveEventFuture = BoxFuture<'static, DocumentSaveEventResult>; +pub type DocumentSavedEventResult = Result; +pub type DocumentSavedEventFuture = BoxFuture<'static, DocumentSavedEventResult>; pub struct Document { pub(crate) id: DocumentId, @@ -133,9 +133,9 @@ pub struct Document { last_saved_revision: usize, version: i32, // should be usize? pub(crate) modified_since_accessed: bool, - save_sender: Option>, - save_receiver: Option>, - current_save: Arc>>, + save_sender: Option>, + save_receiver: Option>, + current_save: Arc>>, diagnostics: Vec, language_server: Option>, @@ -616,7 +616,7 @@ impl Document { let mut file = File::create(&path).await?; to_writer(&mut file, encoding, &text).await?; - let event = DocumentSaveEvent { + let event = DocumentSavedEvent { revision: current_rev, doc_id, path, @@ -643,11 +643,11 @@ impl Document { .map_err(|err| anyhow!("failed to send save event: {}", err)) } - pub async fn await_save(&mut self) -> Option { + pub async fn await_save(&mut self) -> Option { self.await_save_impl(true).await } - async fn await_save_impl(&mut self, block: bool) -> Option { + async fn await_save_impl(&mut self, block: bool) -> Option { let mut current_save = self.current_save.lock().await; if let Some(ref mut save) = *current_save { log::trace!("reawaiting save of '{:?}'", self.path()); @@ -698,11 +698,11 @@ impl Document { /// Flushes the queue of pending writes. If any fail, /// it stops early before emptying the rest of the queue. - pub async fn try_flush_saves(&mut self) -> Option { + pub async fn try_flush_saves(&mut self) -> Option { self.flush_saves_impl(false).await } - async fn flush_saves_impl(&mut self, block: bool) -> Option { + async fn flush_saves_impl(&mut self, block: bool) -> Option { let mut final_result = None; while let Some(save_event) = self.await_save_impl(block).await { @@ -734,7 +734,7 @@ impl Document { /// Prepares the Document for being closed by stopping any new writes /// and flushing through the queue of pending writes. If any fail, /// it stops early before emptying the rest of the queue. - pub async fn close(&mut self) -> Option { + pub async fn close(&mut self) -> Option { if self.save_sender.is_some() { self.save_sender.take(); } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 27b4458f..fbd0b2b0 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1,6 +1,6 @@ use crate::{ clipboard::{get_clipboard_provider, ClipboardProvider}, - document::{DocumentSaveEventResult, Mode}, + document::{DocumentSavedEventResult, Mode}, graphics::{CursorKind, Rect}, info::Info, input::KeyEvent, @@ -691,7 +691,7 @@ pub struct Editor { #[derive(Debug)] pub enum EditorEvent { - DocumentSave(DocumentSaveEventResult), + DocumentSaved(DocumentSavedEventResult), ConfigEvent(ConfigEvent), LanguageServerMessage((usize, Call)), DebuggerEvent(dap::Payload), @@ -1317,7 +1317,7 @@ impl Editor { biased; Some(Some(event)) = saves.next() => { - EditorEvent::DocumentSave(event) + EditorEvent::DocumentSaved(event) } Some(config_event) = self.config_events.1.recv() => { EditorEvent::ConfigEvent(config_event) -- cgit v1.2.3-70-g09d2