Skip to content

Commit b67606c

Browse files
committed
Auto merge of #15529 - SomeoneToIgnore:less-inlay-hint-refreshes, r=Veykril
Do not send inlay hint refresh requests on file edits See rust-lang/rust-analyzer#13369 (comment) Editor itself is able to invalidate hints after edits, and /refresh was sent after editor reports changes to the language server. This forces the editor to either query & invalidate the hints twice after every edit, or wait for /refresh to come before querying the hints. Both options are rather useless, so instead, send a request on server startup only: client editors do not know when the server actually starts up, this will help to query the initial hints after editor was open and the server was still starting up.
2 parents 548d2f0 + 62d1897 commit b67606c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

crates/rust-analyzer/src/global_state.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pub(crate) struct GlobalState {
6969

7070
// status
7171
pub(crate) shutdown_requested: bool,
72+
pub(crate) send_hint_refresh_query: bool,
7273
pub(crate) last_reported_status: Option<lsp_ext::ServerStatusParams>,
7374

7475
// proc macros
@@ -180,6 +181,7 @@ impl GlobalState {
180181
mem_docs: MemDocs::default(),
181182
semantic_tokens_cache: Arc::new(Default::default()),
182183
shutdown_requested: false,
184+
send_hint_refresh_query: false,
183185
last_reported_status: None,
184186
source_root_config: SourceRootConfig::default(),
185187
config_errors: Default::default(),

crates/rust-analyzer/src/main_loop.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,11 @@ impl GlobalState {
320320
}
321321

322322
// Refresh inlay hints if the client supports it.
323-
if self.config.inlay_hints_refresh() {
323+
if (self.send_hint_refresh_query || self.proc_macro_changed)
324+
&& self.config.inlay_hints_refresh()
325+
{
324326
self.send_request::<lsp_types::request::InlayHintRefreshRequest>((), |_, _| ());
327+
self.send_hint_refresh_query = false;
325328
}
326329
}
327330

@@ -538,6 +541,7 @@ impl GlobalState {
538541
}
539542

540543
self.switch_workspaces("fetched build data".to_string());
544+
self.send_hint_refresh_query = true;
541545

542546
(Some(Progress::End), None)
543547
}
@@ -554,7 +558,7 @@ impl GlobalState {
554558
ProcMacroProgress::End(proc_macro_load_result) => {
555559
self.fetch_proc_macros_queue.op_completed(true);
556560
self.set_proc_macros(proc_macro_load_result);
557-
561+
self.send_hint_refresh_query = true;
558562
(Some(Progress::End), None)
559563
}
560564
};

0 commit comments

Comments
 (0)