project: Fix inlay hints duplicatig on chunk start (#41461)
Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -2695,7 +2695,7 @@ let c = 3;"#
|
||||
),
|
||||
(
|
||||
"main.rs",
|
||||
lsp::Range::new(lsp::Position::new(50, 0), lsp::Position::new(100, 11))
|
||||
lsp::Range::new(lsp::Position::new(50, 0), lsp::Position::new(100, 0))
|
||||
),
|
||||
],
|
||||
lsp_request_ranges
|
||||
@@ -2754,7 +2754,7 @@ let c = 3;"#
|
||||
),
|
||||
(
|
||||
"main.rs",
|
||||
lsp::Range::new(lsp::Position::new(50, 0), lsp::Position::new(100, 11))
|
||||
lsp::Range::new(lsp::Position::new(50, 0), lsp::Position::new(100, 0))
|
||||
),
|
||||
],
|
||||
lsp_request_ranges
|
||||
|
||||
@@ -6608,9 +6608,9 @@ impl LspStore {
|
||||
return HashMap::default();
|
||||
}
|
||||
|
||||
let last_chunk_number = applicable_chunks.len() - 1;
|
||||
let last_chunk_number = existing_inlay_hints.buffer_chunks_len() - 1;
|
||||
|
||||
for (i, row_chunk) in applicable_chunks.into_iter().enumerate() {
|
||||
for row_chunk in applicable_chunks {
|
||||
match (
|
||||
existing_inlay_hints
|
||||
.cached_hints(&row_chunk)
|
||||
@@ -6623,7 +6623,7 @@ impl LspStore {
|
||||
.cloned(),
|
||||
) {
|
||||
(None, None) => {
|
||||
let end = if last_chunk_number == i {
|
||||
let end = if last_chunk_number == row_chunk.id {
|
||||
Point::new(row_chunk.end, buffer_snapshot.line_len(row_chunk.end))
|
||||
} else {
|
||||
Point::new(row_chunk.end, 0)
|
||||
|
||||
@@ -67,7 +67,7 @@ struct HintForId {
|
||||
/// <https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#inlayHintParams>
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct BufferChunk {
|
||||
id: usize,
|
||||
pub id: usize,
|
||||
pub start: BufferRow,
|
||||
pub end: BufferRow,
|
||||
}
|
||||
@@ -218,4 +218,8 @@ impl BufferInlayHints {
|
||||
debug_assert_eq!(*hint_id, id, "Invalid pointer {hint_for_id:?}");
|
||||
Some(hint)
|
||||
}
|
||||
|
||||
pub fn buffer_chunks_len(&self) -> usize {
|
||||
self.buffer_chunks.len()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user