mirror of https://github.com/helix-editor/helix
review comments
parent
9e64974f13
commit
31d1bbfddb
|
@ -427,24 +427,25 @@ impl Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) {
|
pub fn handle_document_write(&mut self, doc_save_event: DocumentSavedEventResult) {
|
||||||
if let Err(err) = doc_save_event {
|
let doc_save_event = match doc_save_event {
|
||||||
self.editor.set_error(err.to_string());
|
Ok(event) => event,
|
||||||
return;
|
Err(err) => {
|
||||||
}
|
self.editor.set_error(err.to_string());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let doc_save_event = doc_save_event.unwrap();
|
let doc = match self.editor.document_mut(doc_save_event.doc_id) {
|
||||||
let doc = 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
|
||||||
|
);
|
||||||
|
|
||||||
if doc.is_none() {
|
return;
|
||||||
warn!(
|
}
|
||||||
"received document saved event for non-existent doc id: {}",
|
Some(doc) => doc,
|
||||||
doc_save_event.doc_id
|
};
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let doc = doc.unwrap();
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"document {:?} saved with revision {}",
|
"document {:?} saved with revision {}",
|
||||||
|
@ -472,7 +473,7 @@ impl Application {
|
||||||
let loader = self.editor.syn_loader.clone();
|
let loader = self.editor.syn_loader.clone();
|
||||||
|
|
||||||
// borrowing the same doc again to get around the borrow checker
|
// 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();
|
let id = doc.id();
|
||||||
doc.detect_language(loader);
|
doc.detect_language(loader);
|
||||||
let _ = self.editor.refresh_language_server(id);
|
let _ = self.editor.refresh_language_server(id);
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub struct TypableCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quit(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) -> anyhow::Result<()> {
|
fn quit(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) -> anyhow::Result<()> {
|
||||||
log::info!("quitting...");
|
log::debug!("quitting...");
|
||||||
|
|
||||||
if event != PromptEvent::Validate {
|
if event != PromptEvent::Validate {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
@ -554,12 +554,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let identifier = if self.path().is_some() {
|
let identifier = self.path().map(|_| self.identifier());
|
||||||
Some(self.identifier())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let language_server = self.language_server.clone();
|
let language_server = self.language_server.clone();
|
||||||
|
|
||||||
// mark changes up to now as saved
|
// mark changes up to now as saved
|
||||||
|
@ -708,10 +703,7 @@ impl Document {
|
||||||
/// and flushing through the queue of pending writes. If any fail,
|
/// and flushing through the queue of pending writes. If any fail,
|
||||||
/// it stops early before emptying the rest of the queue.
|
/// it stops early before emptying the rest of the queue.
|
||||||
pub async fn close(&mut self) -> Option<DocumentSavedEventResult> {
|
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
|
self.flush_saves_impl(true).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue