Fix panic on diagnostic hover (#22693)

In #22620 `diagnostic_group` was modified to return results for
multibuffers, but was returning singleton buffer points. `hover_popover`
uses it to find the jump target for clicking the popup - which doesn't
seem to be working right now but that's a separate issue. Now that
`diagnostic_group` is returning values in multibuffers converting these
to anchors was crashing.

Also resolves a potential bug - if folding in multibuffers was supported
then "Go To Diagnostics" would not properly skip diagnostics from folded
regions.

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-05 19:31:02 -07:00 committed by GitHub
parent 94ee2e1811
commit 570e6c80a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 22 deletions

View file

@ -3871,15 +3871,19 @@ impl MultiBufferSnapshot {
.any(|excerpt| excerpt.buffer.has_diagnostics())
}
pub fn diagnostic_group<'a, O>(
&'a self,
pub fn diagnostic_group(
&self,
group_id: usize,
) -> impl Iterator<Item = DiagnosticEntry<O>> + 'a
where
O: text::FromAnchor + 'a,
{
self.all_excerpts()
.flat_map(move |excerpt| excerpt.buffer().diagnostic_group(group_id))
) -> impl Iterator<Item = DiagnosticEntry<Anchor>> + '_ {
self.all_excerpts().flat_map(move |excerpt| {
excerpt.buffer().diagnostic_group(group_id).map(
move |DiagnosticEntry { diagnostic, range }| DiagnosticEntry {
diagnostic,
range: self.anchor_in_excerpt(excerpt.id(), range.start).unwrap()
..self.anchor_in_excerpt(excerpt.id(), range.end).unwrap(),
},
)
})
}
pub fn diagnostics_in_range<'a, T>(