on master help sign in
review comments
31d1bbfSkyler Hawthorne
helix-term/src/application.rs+18−17
@@ -427,24 +427,25 @@ impl Application {
427 }
427 }
428
428
429 pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) {
429 pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) {
430− if let Err(err) = doc_save_event {
430+ let doc_save_event = match doc_save_event {
431+ Ok(event) => event,
432+ Err(err) => {
431− self.editor.set_error(err.to_string());
433+ self.editor.set_error(err.to_string());
432− return;
434+ return;
433− }
435+ }
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− );
436+ };
443
437
444− return;
438+ let doc = match self.editor.document_mut(doc_save_event.doc_id) {
445− }
439+ None => {
440+ warn!(
441+ "received document saved event for non-existent doc id: {}",
442+ doc_save_event.doc_id
443+ );
446
444
447− let doc = doc.unwrap();
445+ return;
446+ }
447+ Some(doc) => doc,
448+ };
448
449
449 debug!(
450 debug!(
450 "document {:?} saved with revision {}",
451 "document {:?} saved with revision {}",
@@ -472,7 +473,7 @@ impl Application {
472 let loader = self.editor.syn_loader.clone();
473 let loader = self.editor.syn_loader.clone();
473
474
474 // borrowing the same doc again to get around the borrow checker
475 // 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);
476 let id = doc.id();
477 let id = doc.id();
477 doc.detect_language(loader);
478 doc.detect_language(loader);
478 let _ = self.editor.refresh_language_server(id);
479 let _ = self.editor.refresh_language_server(id);
helix-term/src/commands/typed.rs+1−1
@@ -21,7 +21,7 @@ pub struct TypableCommand {
21}
21}
22
22
23fn quit(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) -> anyhow::Result<()> {
23fn quit(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) -> anyhow::Result<()> {
24− log::info!("quitting...");
24+ log::debug!("quitting...");
25
25
26 if event != PromptEvent::Validate {
26 if event != PromptEvent::Validate {
27 return Ok(());
27 return Ok(());
helix-view/src/document.rs+2−10
@@ -554,12 +554,7 @@ impl Document {
554 }
554 }
555 };
555 };
556
556
557− let identifier = if self.path().is_some() {
557+ let identifier = self.path().map(|_| self.identifier());
558− Some(self.identifier())
559− } else {
560− None
561− };
562−
563 let language_server = self.language_server.clone();
558 let language_server = self.language_server.clone();
564
559
565 // mark changes up to now as saved
560 // mark changes up to now as saved
@@ -708,10 +703,7 @@ impl Document {
708 /// and flushing through the queue of pending writes. If any fail,
703 /// and flushing through the queue of pending writes. If any fail,
709 /// it stops early before emptying the rest of the queue.
704 /// it stops early before emptying the rest of the queue.
710 pub async fn close(&mut self) -> Option<DocumentSavedEventResult> {
705 pub async fn close(&mut self) -> Option<DocumentSavedEventResult> {
711− if self.save_sender.is_some() {
712− self.save_sender.take();
706+ self.save_sender.take();
713− }
714−
715 self.flush_saves_impl(true).await
707 self.flush_saves_impl(true).await
716 }
708 }
717
709