diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 8b6b461856e..e5d8438d80d 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -69,6 +69,7 @@ pub(crate) struct GlobalState { // status pub(crate) shutdown_requested: bool, + pub(crate) send_hint_refresh_query: bool, pub(crate) last_reported_status: Option, // proc macros @@ -180,6 +181,7 @@ pub(crate) fn new(sender: Sender, config: Config) -> Global mem_docs: MemDocs::default(), semantic_tokens_cache: Arc::new(Default::default()), shutdown_requested: false, + send_hint_refresh_query: false, last_reported_status: None, source_root_config: SourceRootConfig::default(), config_errors: Default::default(), diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index da4bef730b3..cdf41c955d2 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -320,8 +320,11 @@ fn handle_event(&mut self, event: Event) -> anyhow::Result<()> { } // Refresh inlay hints if the client supports it. - if self.config.inlay_hints_refresh() { + if (self.send_hint_refresh_query || self.proc_macro_changed) + && self.config.inlay_hints_refresh() + { self.send_request::((), |_, _| ()); + self.send_hint_refresh_query = false; } } @@ -538,6 +541,7 @@ fn handle_task(&mut self, prime_caches_progress: &mut Vec, } self.switch_workspaces("fetched build data".to_string()); + self.send_hint_refresh_query = true; (Some(Progress::End), None) } @@ -554,7 +558,7 @@ fn handle_task(&mut self, prime_caches_progress: &mut Vec, ProcMacroProgress::End(proc_macro_load_result) => { self.fetch_proc_macros_queue.op_completed(true); self.set_proc_macros(proc_macro_load_result); - + self.send_hint_refresh_query = true; (Some(Progress::End), None) } };