Fix diagnostic unit test
This commit is contained in:
parent
eeba0993aa
commit
cb97b7cd1d
2 changed files with 14 additions and 14 deletions
|
@ -37,20 +37,22 @@ impl DiagnosticSet {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn reset<I>(&mut self, iter: I, buffer: &text::Snapshot)
|
||||
pub fn new<I>(iter: I, buffer: &text::Snapshot) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = DiagnosticEntry<PointUtf16>>,
|
||||
{
|
||||
let mut entries = iter.into_iter().collect::<Vec<_>>();
|
||||
entries.sort_unstable_by_key(|entry| (entry.range.start, Reverse(entry.range.end)));
|
||||
self.diagnostics = SumTree::from_iter(
|
||||
entries.into_iter().map(|entry| DiagnosticEntry {
|
||||
range: buffer.anchor_before(entry.range.start)
|
||||
..buffer.anchor_after(entry.range.end),
|
||||
diagnostic: entry.diagnostic,
|
||||
}),
|
||||
buffer,
|
||||
);
|
||||
Self {
|
||||
diagnostics: SumTree::from_iter(
|
||||
entries.into_iter().map(|entry| DiagnosticEntry {
|
||||
range: buffer.anchor_before(entry.range.start)
|
||||
..buffer.anchor_after(entry.range.end),
|
||||
diagnostic: entry.diagnostic,
|
||||
}),
|
||||
buffer,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &DiagnosticEntry<Anchor>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue