mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-12 05:27:07 +00:00
Invalidate active diagnostic when its primary range collapses
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
b0afc80678
commit
c844fcdc09
1 changed files with 41 additions and 47 deletions
|
@ -344,7 +344,6 @@ struct ActiveDiagnosticGroup {
|
|||
primary_message: String,
|
||||
blocks: HashMap<BlockId, Diagnostic>,
|
||||
is_valid: bool,
|
||||
update_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -2277,14 +2276,12 @@ impl Editor {
|
|||
fn refresh_active_diagnostics(&mut self, cx: &mut ViewContext<Editor>) {
|
||||
if let Some(active_diagnostics) = self.active_diagnostics.as_mut() {
|
||||
let buffer = self.buffer.read(cx);
|
||||
let update_count = buffer.diagnostics_update_count();
|
||||
if update_count > active_diagnostics.update_count {
|
||||
active_diagnostics.update_count = update_count;
|
||||
let primary_range_start = active_diagnostics.primary_range.start.to_offset(buffer);
|
||||
let is_valid = buffer
|
||||
.diagnostics_in_range::<_, usize>(active_diagnostics.primary_range.clone())
|
||||
.any(|(range, diagnostic)| {
|
||||
diagnostic.is_primary
|
||||
&& !range.is_empty()
|
||||
&& range.start == primary_range_start
|
||||
&& diagnostic.message == active_diagnostics.primary_message
|
||||
});
|
||||
|
@ -2325,14 +2322,12 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn activate_diagnostics(&mut self, group_id: usize, cx: &mut ViewContext<Self>) {
|
||||
self.dismiss_diagnostics(cx);
|
||||
self.active_diagnostics = self.display_map.update(cx, |display_map, cx| {
|
||||
let buffer = self.buffer.read(cx);
|
||||
|
||||
let update_count = buffer.diagnostics_update_count();
|
||||
let mut primary_range = None;
|
||||
let mut primary_message = None;
|
||||
let mut group_end = Point::zero();
|
||||
|
@ -2400,7 +2395,6 @@ impl Editor {
|
|||
primary_message,
|
||||
blocks,
|
||||
is_valid: true,
|
||||
update_count,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue