Ignore diagnostics with empty ranges

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-11-19 16:30:26 +01:00
parent a023950f28
commit b0afc80678
2 changed files with 2 additions and 0 deletions

View File

@ -2242,6 +2242,7 @@ impl Editor {
.diagnostics_in_range::<_, usize>(search_start..buffer.len())
.find_map(|(range, diagnostic)| {
if diagnostic.is_primary
&& !range.is_empty()
&& Some(range.end) != active_primary_range.as_ref().map(|r| *r.end())
{
Some((range, diagnostic.group_id))

View File

@ -263,6 +263,7 @@ impl DiagnosticMessage {
.buffer()
.read(cx)
.diagnostics_in_range::<usize, usize>(cursor_position..cursor_position)
.filter(|(range, _)| !range.is_empty())
.min_by_key(|(range, diagnostic)| (diagnostic.severity, range.len()))
.map(|(_, diagnostic)| diagnostic.clone());
if new_diagnostic != self.diagnostic {