diff options
-rw-r--r-- | helix-term/src/application.rs | 35 | ||||
-rw-r--r-- | helix-term/src/commands/typed.rs | 2 | ||||
-rw-r--r-- | helix-view/src/document.rs | 12 |
3 files changed, 21 insertions, 28 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 4fde2a66..694c55c0 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -427,24 +427,25 @@ impl Application { } 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; - } - - let doc_save_event = doc_save_event.unwrap(); - let doc = self.editor.document_mut(doc_save_event.doc_id); - - if doc.is_none() { - warn!( - "received document saved event for non-existent doc id: {}", - doc_save_event.doc_id - ); + let doc_save_event = match doc_save_event { + Ok(event) => event, + Err(err) => { + self.editor.set_error(err.to_string()); + return; + } + }; - return; - } + let doc = match self.editor.document_mut(doc_save_event.doc_id) { + None => { + warn!( + "received document saved event for non-existent doc id: {}", + doc_save_event.doc_id + ); - let doc = doc.unwrap(); + return; + } + Some(doc) => doc, + }; debug!( "document {:?} saved with revision {}", @@ -472,7 +473,7 @@ impl Application { let loader = self.editor.syn_loader.clone(); // borrowing the same doc again to get around the borrow checker - let doc = self.editor.document_mut(doc_save_event.doc_id).unwrap(); + let doc = doc_mut!(self.editor, &doc_save_event.doc_id); let id = doc.id(); doc.detect_language(loader); let _ = self.editor.refresh_language_server(id); diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index d312c45f..070215cb 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -21,7 +21,7 @@ pub struct TypableCommand { } fn quit(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) -> anyhow::Result<()> { - log::info!("quitting..."); + log::debug!("quitting..."); if event != PromptEvent::Validate { return Ok(()); diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 4a09bedc..0774e516 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -554,12 +554,7 @@ impl Document { } }; - let identifier = if self.path().is_some() { - Some(self.identifier()) - } else { - None - }; - + let identifier = self.path().map(|_| self.identifier()); let language_server = self.language_server.clone(); // mark changes up to now as saved @@ -708,10 +703,7 @@ impl Document { /// 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<DocumentSavedEventResult> { - if self.save_sender.is_some() { - self.save_sender.take(); - } - + self.save_sender.take(); self.flush_saves_impl(true).await } |