From 58db38722b57f8531fab877be548c44a9a785229 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 11 Nov 2025 15:38:28 +0200 Subject: [PATCH] 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 Co-authored-by: Lukas Wirth --- crates/project/src/lsp_store/inlay_hint_cache.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/project/src/lsp_store/inlay_hint_cache.rs b/crates/project/src/lsp_store/inlay_hint_cache.rs index 51189d8fdae788c7c12546f2c9ac1735930c3095..cca9d66e8c330f1a4c723a84c4fb418b976f7c03 100644 --- a/crates/project/src/lsp_store/inlay_hint_cache.rs +++ b/crates/project/src/lsp_store/inlay_hint_cache.rs @@ -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::>(); 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() }