Refactor add_diagnostics

pull/11315/head
Sofus Addington 3 months ago
parent daede03dc6
commit 131574983a

@ -2169,19 +2169,21 @@ impl Editor {
document_version: Option<i32>, document_version: Option<i32>,
result_id: Option<String>, result_id: Option<String>,
) { ) {
let doc = self.documents.values_mut() let Some(doc) = self
.documents
.values_mut()
.find(|doc| doc.uri().is_some_and(|u| u == uri)) .find(|doc| doc.uri().is_some_and(|u| u == uri))
.filter(|doc| { else {
if let Some(version) = document_version{ return;
};
if let Some(version) = document_version {
if version != doc.version() { if version != doc.version() {
log::info!("Version ({version}) is out of date for {uri:?} (expected ({}), dropping PublishDiagnostic notification", doc.version()); log::info!("Version ({version}) is out of date for {uri:?} (expected ({}), dropping PublishDiagnostic notification", doc.version());
return false; return;
} }
} }
true
});
if let Some(doc) = doc {
let mut unchanged_diag_sources = Vec::new(); let mut unchanged_diag_sources = Vec::new();
if let Some(old_diagnostics) = self.diagnostics.get(&uri) { if let Some(old_diagnostics) = self.diagnostics.get(&uri) {
if let Some(lang_conf) = doc.language_config() { if let Some(lang_conf) = doc.language_config() {
@ -2245,7 +2247,6 @@ impl Editor {
helix_event::dispatch(crate::events::DiagnosticsDidChange { editor: self, doc }); helix_event::dispatch(crate::events::DiagnosticsDidChange { editor: self, doc });
} }
}
} }
fn try_restore_indent(doc: &mut Document, view: &mut View) { fn try_restore_indent(doc: &mut Document, view: &mut View) {

Loading…
Cancel
Save