mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Fix diagnostic unit test
This commit is contained in:
parent
eeba0993aa
commit
cb97b7cd1d
2 changed files with 14 additions and 14 deletions
|
@ -23,7 +23,6 @@ use std::{
|
|||
ffi::OsString,
|
||||
future::Future,
|
||||
iter::{Iterator, Peekable},
|
||||
mem,
|
||||
ops::{Deref, DerefMut, Range},
|
||||
path::{Path, PathBuf},
|
||||
str,
|
||||
|
@ -794,8 +793,7 @@ impl Buffer {
|
|||
}
|
||||
|
||||
drop(edits_since_save);
|
||||
let mut diagnostics = mem::take(&mut self.diagnostics);
|
||||
diagnostics.reset(
|
||||
let new_diagnostics = DiagnosticSet::new(
|
||||
diagnostics_by_group_id
|
||||
.into_values()
|
||||
.flat_map(|mut diagnostics| {
|
||||
|
@ -806,9 +804,9 @@ impl Buffer {
|
|||
primary.diagnostic.is_primary = true;
|
||||
diagnostics
|
||||
}),
|
||||
self,
|
||||
content,
|
||||
);
|
||||
self.diagnostics = diagnostics;
|
||||
self.diagnostics = new_diagnostics;
|
||||
|
||||
if let Some(version) = version {
|
||||
let language_server = self.language_server.as_mut().unwrap();
|
||||
|
|
|
@ -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…
Reference in a new issue