on master help sign in
Rename doc save event names to past tense
f82a551Skyler Hawthorne
helix-term/src/application.rs+3−3
@@ -9,7 +9,7 @@ use helix_core::{
9use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
9use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
10use helix_view::{
10use helix_view::{
11 align_view,
11 align_view,
12− document::DocumentSaveEventResult,
12+ document::DocumentSavedEventResult,
13 editor::{ConfigEvent, EditorEvent},
13 editor::{ConfigEvent, EditorEvent},
14 theme,
14 theme,
15 tree::Layout,
15 tree::Layout,
@@ -431,7 +431,7 @@ impl Application {
431 }
431 }
432 }
432 }
433
433
434− pub fn handle_document_write(&mut self, doc_save_event: DocumentSaveEventResult) {
434+ pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) {
435 if let Err(err) = doc_save_event {
435 if let Err(err) = doc_save_event {
436 self.editor.set_error(err.to_string());
436 self.editor.set_error(err.to_string());
437 return;
437 return;
@@ -485,7 +485,7 @@ impl Application {
485 log::debug!("received editor event: {:?}", event);
485 log::debug!("received editor event: {:?}", event);
486
486
487 match event {
487 match event {
488− EditorEvent::DocumentSave(event) => {
488+ EditorEvent::DocumentSaved(event) => {
489 self.handle_document_write(event);
489 self.handle_document_write(event);
490 self.render();
490 self.render();
491 }
491 }
helix-term/src/job.rs+1
@@ -107,6 +107,7 @@ impl Jobs {
107 ) -> anyhow::Result<()> {
107 ) -> anyhow::Result<()> {
108 log::debug!("waiting on jobs...");
108 log::debug!("waiting on jobs...");
109 let mut wait_futures = std::mem::take(&mut self.wait_futures);
109 let mut wait_futures = std::mem::take(&mut self.wait_futures);
110+
110 while let (Some(job), tail) = wait_futures.into_future().await {
111 while let (Some(job), tail) = wait_futures.into_future().await {
111 match job {
112 match job {
112 Ok(callback) => {
113 Ok(callback) => {
helix-view/src/document.rs+12−12
@@ -89,14 +89,14 @@ impl Serialize for Mode {
89
89
90/// A snapshot of the text of a document that we want to write out to disk
90/// A snapshot of the text of a document that we want to write out to disk
91#[derive(Debug, Clone)]
91#[derive(Debug, Clone)]
92−pub struct DocumentSaveEvent {
92+pub struct DocumentSavedEvent {
93 pub revision: usize,
93 pub revision: usize,
94 pub doc_id: DocumentId,
94 pub doc_id: DocumentId,
95 pub path: PathBuf,
95 pub path: PathBuf,
96}
96}
97
97
98−pub type DocumentSaveEventResult = Result<DocumentSaveEvent, anyhow::Error>;
98+pub type DocumentSavedEventResult = Result<DocumentSavedEvent, anyhow::Error>;
99−pub type DocumentSaveEventFuture = BoxFuture<'static, DocumentSaveEventResult>;
99+pub type DocumentSavedEventFuture = BoxFuture<'static, DocumentSavedEventResult>;
100
100
101pub struct Document {
101pub struct Document {
102 pub(crate) id: DocumentId,
102 pub(crate) id: DocumentId,
@@ -133,9 +133,9 @@ pub struct Document {
133 last_saved_revision: usize,
133 last_saved_revision: usize,
134 version: i32, // should be usize?
134 version: i32, // should be usize?
135 pub(crate) modified_since_accessed: bool,
135 pub(crate) modified_since_accessed: bool,
136− save_sender: Option<UnboundedSender<DocumentSaveEventFuture>>,
136+ save_sender: Option<UnboundedSender<DocumentSavedEventFuture>>,
137− save_receiver: Option<UnboundedReceiver<DocumentSaveEventFuture>>,
137+ save_receiver: Option<UnboundedReceiver<DocumentSavedEventFuture>>,
138− current_save: Arc<Mutex<Option<DocumentSaveEventFuture>>>,
138+ current_save: Arc<Mutex<Option<DocumentSavedEventFuture>>>,
139
139
140 diagnostics: Vec<Diagnostic>,
140 diagnostics: Vec<Diagnostic>,
141 language_server: Option<Arc<helix_lsp::Client>>,
141 language_server: Option<Arc<helix_lsp::Client>>,
@@ -616,7 +616,7 @@ impl Document {
616 let mut file = File::create(&path).await?;
616 let mut file = File::create(&path).await?;
617 to_writer(&mut file, encoding, &text).await?;
617 to_writer(&mut file, encoding, &text).await?;
618
618
619− let event = DocumentSaveEvent {
619+ let event = DocumentSavedEvent {
620 revision: current_rev,
620 revision: current_rev,
621 doc_id,
621 doc_id,
622 path,
622 path,
@@ -643,11 +643,11 @@ impl Document {
643 .map_err(|err| anyhow!("failed to send save event: {}", err))
643 .map_err(|err| anyhow!("failed to send save event: {}", err))
644 }
644 }
645
645
646− pub async fn await_save(&mut self) -> Option<DocumentSaveEventResult> {
646+ pub async fn await_save(&mut self) -> Option<DocumentSavedEventResult> {
647 self.await_save_impl(true).await
647 self.await_save_impl(true).await
648 }
648 }
649
649
650− async fn await_save_impl(&mut self, block: bool) -> Option<DocumentSaveEventResult> {
650+ async fn await_save_impl(&mut self, block: bool) -> Option<DocumentSavedEventResult> {
651 let mut current_save = self.current_save.lock().await;
651 let mut current_save = self.current_save.lock().await;
652 if let Some(ref mut save) = *current_save {
652 if let Some(ref mut save) = *current_save {
653 log::trace!("reawaiting save of '{:?}'", self.path());
653 log::trace!("reawaiting save of '{:?}'", self.path());
@@ -698,11 +698,11 @@ impl Document {
698
698
699 /// Flushes the queue of pending writes. If any fail,
699 /// Flushes the queue of pending writes. If any fail,
700 /// it stops early before emptying the rest of the queue.
700 /// 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> {
702 self.flush_saves_impl(false).await
702 self.flush_saves_impl(false).await
703 }
703 }
704
704
705− async fn flush_saves_impl(&mut self, block: bool) -> Option<DocumentSaveEventResult> {
705+ async fn flush_saves_impl(&mut self, block: bool) -> Option<DocumentSavedEventResult> {
706 let mut final_result = None;
706 let mut final_result = None;
707
707
708 while let Some(save_event) = self.await_save_impl(block).await {
708 while let Some(save_event) = self.await_save_impl(block).await {
@@ -734,7 +734,7 @@ impl Document {
734 /// Prepares the Document for being closed by stopping any new writes
734 /// Prepares the Document for being closed by stopping any new writes
735 /// and flushing through the queue of pending writes. If any fail,
735 /// and flushing through the queue of pending writes. If any fail,
736 /// it stops early before emptying the rest of the queue.
736 /// 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> {
738 if self.save_sender.is_some() {
738 if self.save_sender.is_some() {
739 self.save_sender.take();
739 self.save_sender.take();
740 }
740 }
helix-view/src/editor.rs+3−3
@@ -1,6 +1,6 @@
1use crate::{
1use crate::{
2 clipboard::{get_clipboard_provider, ClipboardProvider},
2 clipboard::{get_clipboard_provider, ClipboardProvider},
3− document::{DocumentSaveEventResult, Mode},
3+ document::{DocumentSavedEventResult, Mode},
4 graphics::{CursorKind, Rect},
4 graphics::{CursorKind, Rect},
5 info::Info,
5 info::Info,
6 input::KeyEvent,
6 input::KeyEvent,
@@ -691,7 +691,7 @@ pub struct Editor {
691
691
692#[derive(Debug)]
692#[derive(Debug)]
693pub enum EditorEvent {
693pub enum EditorEvent {
694− DocumentSave(DocumentSaveEventResult),
694+ DocumentSaved(DocumentSavedEventResult),
695 ConfigEvent(ConfigEvent),
695 ConfigEvent(ConfigEvent),
696 LanguageServerMessage((usize, Call)),
696 LanguageServerMessage((usize, Call)),
697 DebuggerEvent(dap::Payload),
697 DebuggerEvent(dap::Payload),
@@ -1317,7 +1317,7 @@ impl Editor {
1317 biased;
1317 biased;
1318
1318
1319 Some(Some(event)) = saves.next() => {
1319 Some(Some(event)) = saves.next() => {
1320− EditorEvent::DocumentSave(event)
1320+ EditorEvent::DocumentSaved(event)
1321 }
1321 }
1322 Some(config_event) = self.config_events.1.recv() => {
1322 Some(config_event) = self.config_events.1.recv() => {
1323 EditorEvent::ConfigEvent(config_event)
1323 EditorEvent::ConfigEvent(config_event)