Show diagnostics in scrollbar (#7175)

This PR implements support for displaying diagnostics in the scrollbar,
similar to what is already done for search results, symbols, git diff,
...

For example, changing a field name (`text`) without changing the
references looks like this in `buffer.rs` (note the red lines in the
scrollbar):

![image](https://github.com/zed-industries/zed/assets/53836821/c46f0d55-32e3-4334-8ad7-66d1578d5725)

As you can see, the errors, warnings, ... are displayed in the scroll
bar, which helps to identify possible problems with the current file.

Relevant issues: #4866, #6819

Release Notes:

- Added diagnostic indicators to the scrollbar
This commit is contained in:
Bennet Bo Fenner 2024-02-02 11:10:42 +01:00 committed by GitHub
parent 2940a0ebd8
commit ce4c15dca6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 81 additions and 1 deletions

View file

@ -2993,6 +2993,11 @@ impl BufferSnapshot {
self.git_diff.hunks_intersecting_range_rev(range, self)
}
/// Returns if the buffer contains any diagnostics.
pub fn has_diagnostics(&self) -> bool {
!self.diagnostics.is_empty()
}
/// Returns all the diagnostics intersecting the given range.
pub fn diagnostics_in_range<'a, T, O>(
&'a self,