Avoid crash when clicking the popover of a diagnostic that's been removed
This commit is contained in:
parent
039c94c829
commit
e1431ede36
1 changed files with 22 additions and 19 deletions
|
@ -4661,12 +4661,13 @@ impl Editor {
|
||||||
if direction == Direction::Next {
|
if direction == Direction::Next {
|
||||||
if let Some(popover) = self.hover_state.diagnostic_popover.as_ref() {
|
if let Some(popover) = self.hover_state.diagnostic_popover.as_ref() {
|
||||||
let (group_id, jump_to) = popover.activation_info();
|
let (group_id, jump_to) = popover.activation_info();
|
||||||
self.activate_diagnostics(group_id, cx);
|
if self.activate_diagnostics(group_id, cx) {
|
||||||
self.change_selections(Some(Autoscroll::Center), cx, |s| {
|
self.change_selections(Some(Autoscroll::Center), cx, |s| {
|
||||||
let mut new_selection = s.newest_anchor().clone();
|
let mut new_selection = s.newest_anchor().clone();
|
||||||
new_selection.collapse_to(jump_to, SelectionGoal::None);
|
new_selection.collapse_to(jump_to, SelectionGoal::None);
|
||||||
s.select_anchors(vec![new_selection.clone()]);
|
s.select_anchors(vec![new_selection.clone()]);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4706,16 +4707,17 @@ impl Editor {
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some((primary_range, group_id)) = group {
|
if let Some((primary_range, group_id)) = group {
|
||||||
self.activate_diagnostics(group_id, cx);
|
if self.activate_diagnostics(group_id, cx) {
|
||||||
self.change_selections(Some(Autoscroll::Center), cx, |s| {
|
self.change_selections(Some(Autoscroll::Center), cx, |s| {
|
||||||
s.select(vec![Selection {
|
s.select(vec![Selection {
|
||||||
id: selection.id,
|
id: selection.id,
|
||||||
start: primary_range.start,
|
start: primary_range.start,
|
||||||
end: primary_range.start,
|
end: primary_range.start,
|
||||||
reversed: false,
|
reversed: false,
|
||||||
goal: SelectionGoal::None,
|
goal: SelectionGoal::None,
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// Cycle around to the start of the buffer, potentially moving back to the start of
|
// Cycle around to the start of the buffer, potentially moving back to the start of
|
||||||
|
@ -5162,7 +5164,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activate_diagnostics(&mut self, group_id: usize, cx: &mut ViewContext<Self>) {
|
fn activate_diagnostics(&mut self, group_id: usize, cx: &mut ViewContext<Self>) -> bool {
|
||||||
self.dismiss_diagnostics(cx);
|
self.dismiss_diagnostics(cx);
|
||||||
self.active_diagnostics = self.display_map.update(cx, |display_map, cx| {
|
self.active_diagnostics = self.display_map.update(cx, |display_map, cx| {
|
||||||
let buffer = self.buffer.read(cx).snapshot(cx);
|
let buffer = self.buffer.read(cx).snapshot(cx);
|
||||||
|
@ -5183,8 +5185,8 @@ impl Editor {
|
||||||
entry
|
entry
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let primary_range = primary_range.unwrap();
|
let primary_range = primary_range?;
|
||||||
let primary_message = primary_message.unwrap();
|
let primary_message = primary_message?;
|
||||||
let primary_range =
|
let primary_range =
|
||||||
buffer.anchor_after(primary_range.start)..buffer.anchor_before(primary_range.end);
|
buffer.anchor_after(primary_range.start)..buffer.anchor_before(primary_range.end);
|
||||||
|
|
||||||
|
@ -5214,6 +5216,7 @@ impl Editor {
|
||||||
is_valid: true,
|
is_valid: true,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
self.active_diagnostics.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dismiss_diagnostics(&mut self, cx: &mut ViewContext<Self>) {
|
fn dismiss_diagnostics(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue