on master help sign in
Rename doc save event names to past tense
commitf82a551b98cec165ac91aae15ba656a811229fde authorSkyler Hawthorne <skyler@dead10ck.com> dateTue 30 Aug 2022, 23:08 (4 years ago) parent6cffc7f
4 files changed+19−18
helix-term/src/application.rs+3−3 helix-term/src/job.rs+1 helix-view/src/document.rs+12−12 helix-view/src/editor.rs+3−3
helix-term/src/application.rs+3−3
@@ -9,7 +9,7 @@ use helix_core::{
99use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
1010use helix_view::{
1111 align_view,
12− document::DocumentSaveEventResult,
12+ document::DocumentSavedEventResult,
1313 editor::{ConfigEvent, EditorEvent},
1414 theme,
1515 tree::Layout,
@@ -431,7 +431,7 @@ impl Application {
431431 }
432432 }
433433
434− pub fn handle_document_write(&mut self, doc_save_event: DocumentSaveEventResult) {
434+ pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) {
435435 if let Err(err) = doc_save_event {
436436 self.editor.set_error(err.to_string());
437437 return;
@@ -485,7 +485,7 @@ impl Application {
485485 log::debug!("received editor event: {:?}", event);
486486
487487 match event {
488− EditorEvent::DocumentSave(event) => {
488+ EditorEvent::DocumentSaved(event) => {
489489 self.handle_document_write(event);
490490 self.render();
491491 }
helix-term/src/job.rs+1
@@ -107,6 +107,7 @@ impl Jobs {
107107 ) -> anyhow::Result<()> {
108108 log::debug!("waiting on jobs...");
109109 let mut wait_futures = std::mem::take(&mut self.wait_futures);
110+
110111 while let (Some(job), tail) = wait_futures.into_future().await {
111112 match job {
112113 Ok(callback) => {
helix-view/src/document.rs+12−12
@@ -89,14 +89,14 @@ impl Serialize for Mode {
8989
9090/// A snapshot of the text of a document that we want to write out to disk
9191#[derive(Debug, Clone)]
92−pub struct DocumentSaveEvent {
92+pub struct DocumentSavedEvent {
9393 pub revision: usize,
9494 pub doc_id: DocumentId,
9595 pub path: PathBuf,
9696}
9797
98−pub type DocumentSaveEventResult = Result<DocumentSaveEvent, anyhow::Error>;
99−pub type DocumentSaveEventFuture = BoxFuture<'static, DocumentSaveEventResult>;
98+pub type DocumentSavedEventResult = Result<DocumentSavedEvent, anyhow::Error>;
99+pub type DocumentSavedEventFuture = BoxFuture<'static, DocumentSavedEventResult>;
100100
101101pub struct Document {
102102 pub(crate) id: DocumentId,
@@ -133,9 +133,9 @@ pub struct Document {
133133 last_saved_revision: usize,
134134 version: i32, // should be usize?
135135 pub(crate) modified_since_accessed: bool,
136− save_sender: Option<UnboundedSender<DocumentSaveEventFuture>>,
137− save_receiver: Option<UnboundedReceiver<DocumentSaveEventFuture>>,
138− current_save: Arc<Mutex<Option<DocumentSaveEventFuture>>>,
136+ save_sender: Option<UnboundedSender<DocumentSavedEventFuture>>,
137+ save_receiver: Option<UnboundedReceiver<DocumentSavedEventFuture>>,
138+ current_save: Arc<Mutex<Option<DocumentSavedEventFuture>>>,
139139
140140 diagnostics: Vec<Diagnostic>,
141141 language_server: Option<Arc<helix_lsp::Client>>,
@@ -616,7 +616,7 @@ impl Document {
616616 let mut file = File::create(&path).await?;
617617 to_writer(&mut file, encoding, &text).await?;
618618
619− let event = DocumentSaveEvent {
619+ let event = DocumentSavedEvent {
620620 revision: current_rev,
621621 doc_id,
622622 path,
@@ -643,11 +643,11 @@ impl Document {
643643 .map_err(|err| anyhow!("failed to send save event: {}", err))
644644 }
645645
646− pub async fn await_save(&mut self) -> Option<DocumentSaveEventResult> {
646+ pub async fn await_save(&mut self) -> Option<DocumentSavedEventResult> {
647647 self.await_save_impl(true).await
648648 }
649649
650− async fn await_save_impl(&mut self, block: bool) -> Option<DocumentSaveEventResult> {
650+ async fn await_save_impl(&mut self, block: bool) -> Option<DocumentSavedEventResult> {
651651 let mut current_save = self.current_save.lock().await;
652652 if let Some(ref mut save) = *current_save {
653653 log::trace!("reawaiting save of '{:?}'", self.path());
@@ -698,11 +698,11 @@ impl Document {
698698
699699 /// Flushes the queue of pending writes. If any fail,
700700 /// it stops early before emptying the rest of the queue.
701− pub async fn try_flush_saves(&mut self) -> Option<DocumentSaveEventResult> {
701+ pub async fn try_flush_saves(&mut self) -> Option<DocumentSavedEventResult> {
702702 self.flush_saves_impl(false).await
703703 }
704704
705− async fn flush_saves_impl(&mut self, block: bool) -> Option<DocumentSaveEventResult> {
705+ async fn flush_saves_impl(&mut self, block: bool) -> Option<DocumentSavedEventResult> {
706706 let mut final_result = None;
707707
708708 while let Some(save_event) = self.await_save_impl(block).await {
@@ -734,7 +734,7 @@ impl Document {
734734 /// Prepares the Document for being closed by stopping any new writes
735735 /// and flushing through the queue of pending writes. If any fail,
736736 /// it stops early before emptying the rest of the queue.
737− pub async fn close(&mut self) -> Option<DocumentSaveEventResult> {
737+ pub async fn close(&mut self) -> Option<DocumentSavedEventResult> {
738738 if self.save_sender.is_some() {
739739 self.save_sender.take();
740740 }
helix-view/src/editor.rs+3−3
@@ -1,6 +1,6 @@
11use crate::{
22 clipboard::{get_clipboard_provider, ClipboardProvider},
3− document::{DocumentSaveEventResult, Mode},
3+ document::{DocumentSavedEventResult, Mode},
44 graphics::{CursorKind, Rect},
55 info::Info,
66 input::KeyEvent,
@@ -691,7 +691,7 @@ pub struct Editor {
691691
692692#[derive(Debug)]
693693pub enum EditorEvent {
694− DocumentSave(DocumentSaveEventResult),
694+ DocumentSaved(DocumentSavedEventResult),
695695 ConfigEvent(ConfigEvent),
696696 LanguageServerMessage((usize, Call)),
697697 DebuggerEvent(dap::Payload),
@@ -1317,7 +1317,7 @@ impl Editor {
13171317 biased;
13181318
13191319 Some(Some(event)) = saves.next() => {
1320− EditorEvent::DocumentSave(event)
1320+ EditorEvent::DocumentSaved(event)
13211321 }
13221322 Some(config_event) = self.config_events.1.recv() => {
13231323 EditorEvent::ConfigEvent(config_event)