From 9371197182ce63b51469789064ac1aabb2b93388 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 28 Apr 2024 17:35:43 +0200 Subject: [PATCH] Retry inlay hint requests --- crates/rust-analyzer/src/handlers/request.rs | 6 +++++- crates/rust-analyzer/src/main_loop.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index 88dac17d6e79..90851ac7c562 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -937,7 +937,7 @@ pub(crate) fn handle_completion( lsp_types::CompletionParams { text_document_position, context,.. }: lsp_types::CompletionParams, ) -> anyhow::Result> { let _p = tracing::span!(tracing::Level::INFO, "handle_completion").entered(); - let mut position = from_proto::file_position(&snap, text_document_position)?; + let mut position = from_proto::file_position(&snap, text_document_position.clone())?; let line_index = snap.file_line_index(position.file_id)?; let completion_trigger_character = context.and_then(|ctx| ctx.trigger_character).and_then(|s| s.chars().next()); @@ -1505,6 +1505,10 @@ pub(crate) fn handle_inlay_hints( )?; let line_index = snap.file_line_index(file_id)?; let source_root = snap.analysis.source_root(file_id)?; + let range = TextRange::new( + range.start().min(line_index.index.len()), + range.end().min(line_index.index.len()), + ); let inlay_hints_config = snap.config.inlay_hints(Some(source_root)); Ok(Some( diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 9c1d955dd7d3..aee31623081a 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -947,7 +947,7 @@ impl GlobalState { .on::(handlers::handle_goto_declaration) .on::(handlers::handle_goto_implementation) .on::(handlers::handle_goto_type_definition) - .on::(handlers::handle_inlay_hints) + .on::(handlers::handle_inlay_hints) .on::(handlers::handle_inlay_hints_resolve) .on::(handlers::handle_code_lens) .on::(handlers::handle_code_lens_resolve)