on master help sign in
review comments
commit31d1bbfddb112a1e38cf974793afc427a3614ecf authorSkyler Hawthorne <skyler@dead10ck.com> dateWed 21 Sep 2022, 18:34 (4 years ago) parent9e64974
3 files changed+21−28
helix-term/src/application.rs+18−17 helix-term/src/commands/typed.rs+1−1 helix-view/src/document.rs+2−10
helix-term/src/application.rs+18−17
@@ -427,24 +427,25 @@ impl Application {
427427 }
428428
429429 pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) {
430− if let Err(err) = doc_save_event {
431− self.editor.set_error(err.to_string());
432− return;
433− }
434−
435− let doc_save_event = doc_save_event.unwrap();
436− let doc = self.editor.document_mut(doc_save_event.doc_id);
437−
438− if doc.is_none() {
439− warn!(
440− "received document saved event for non-existent doc id: {}",
441− doc_save_event.doc_id
442− );
430+ let doc_save_event = match doc_save_event {
431+ Ok(event) => event,
432+ Err(err) => {
433+ self.editor.set_error(err.to_string());
434+ return;
435+ }
436+ };
443437
444− return;
445− }
438+ let doc = match self.editor.document_mut(doc_save_event.doc_id) {
439+ None => {
440+ warn!(
441+ "received document saved event for non-existent doc id: {}",
442+ doc_save_event.doc_id
443+ );
446444
447− let doc = doc.unwrap();
445+ return;
446+ }
447+ Some(doc) => doc,
448+ };
448449
449450 debug!(
450451 "document {:?} saved with revision {}",
@@ -472,7 +473,7 @@ impl Application {
472473 let loader = self.editor.syn_loader.clone();
473474
474475 // borrowing the same doc again to get around the borrow checker
475− let doc = self.editor.document_mut(doc_save_event.doc_id).unwrap();
476+ let doc = doc_mut!(self.editor, &doc_save_event.doc_id);
476477 let id = doc.id();
477478 doc.detect_language(loader);
478479 let _ = self.editor.refresh_language_server(id);
helix-term/src/commands/typed.rs+1−1
@@ -21,7 +21,7 @@ pub struct TypableCommand {
2121}
2222
2323fn quit(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) -> anyhow::Result<()> {
24− log::info!("quitting...");
24+ log::debug!("quitting...");
2525
2626 if event != PromptEvent::Validate {
2727 return Ok(());
helix-view/src/document.rs+2−10
@@ -554,12 +554,7 @@ impl Document {
554554 }
555555 };
556556
557− let identifier = if self.path().is_some() {
558− Some(self.identifier())
559− } else {
560− None
561− };
562−
557+ let identifier = self.path().map(|_| self.identifier());
563558 let language_server = self.language_server.clone();
564559
565560 // mark changes up to now as saved
@@ -708,10 +703,7 @@ impl Document {
708703 /// and flushing through the queue of pending writes. If any fail,
709704 /// it stops early before emptying the rest of the queue.
710705 pub async fn close(&mut self) -> Option<DocumentSavedEventResult> {
711− if self.save_sender.is_some() {
712− self.save_sender.take();
713− }
714−
706+ self.save_sender.take();
715707 self.flush_saves_impl(true).await
716708 }
717709