Find proper applicable chunks for visible ranges (#42422)
Release Notes: - Fixed inlay hints not being queried for certain long-ranged jumps Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Lukas Wirth <lukas@zed.dev>
This commit is contained in:
co-authored by
Smit Barmase
Lukas Wirth
parent
f2ad0d716f
commit
58db38722b
@@ -6,6 +6,7 @@ use gpui::{App, Entity, Task};
|
||||
use language::{Buffer, BufferRow, BufferSnapshot};
|
||||
use lsp::LanguageServerId;
|
||||
use text::OffsetRangeExt;
|
||||
use util::RangeExt as _;
|
||||
|
||||
use crate::{InlayHint, InlayId};
|
||||
|
||||
@@ -123,18 +124,17 @@ impl BufferInlayHints {
|
||||
let row_ranges = ranges
|
||||
.iter()
|
||||
.map(|range| range.to_point(&self.snapshot))
|
||||
.map(|point_range| point_range.start.row..=point_range.end.row)
|
||||
// Be lenient and yield multiple chunks if they "touch" the exclusive part of the range.
|
||||
// This will result in LSP hints [re-]queried for more ranges, but also more hints already visible when scrolling around.
|
||||
.map(|point_range| point_range.start.row..point_range.end.row + 1)
|
||||
.collect::<Vec<_>>();
|
||||
self.buffer_chunks
|
||||
.iter()
|
||||
.filter(move |chunk| -> bool {
|
||||
// Be lenient and yield multiple chunks if they "touch" the exclusive part of the range.
|
||||
// This will result in LSP hints [re-]queried for more ranges, but also more hints already visible when scrolling around.
|
||||
.filter(move |chunk| {
|
||||
let chunk_range = chunk.start..=chunk.end;
|
||||
row_ranges.iter().any(|row_range| {
|
||||
chunk_range.contains(&row_range.start())
|
||||
|| chunk_range.contains(&row_range.end())
|
||||
})
|
||||
row_ranges
|
||||
.iter()
|
||||
.any(|row_range| chunk_range.overlaps(&row_range))
|
||||
})
|
||||
.copied()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user