From 6b46095980bf73512f5ed06d0659d263a4c990df Mon Sep 17 00:00:00 2001 From: Luna Razzaghipour Date: Sun, 28 May 2023 22:10:24 +1000 Subject: [PATCH] Make formatting a latency-sensitive request --- crates/rust-analyzer/src/main_loop.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 34947fcd6f9..19c49a23000 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -695,6 +695,14 @@ fn on_request(&mut self, req: Request) { .on_latency_sensitive::( handlers::handle_semantic_tokens_range, ) + // Formatting is not caused by the user typing, + // but it does qualify as latency-sensitive + // because a delay before formatting is applied + // can be confusing for the user. + .on_latency_sensitive::(handlers::handle_formatting) + .on_latency_sensitive::( + handlers::handle_range_formatting, + ) // All other request handlers .on::(handlers::fetch_dependency_list) .on::(handlers::handle_analyzer_status) @@ -730,8 +738,6 @@ fn on_request(&mut self, req: Request) { .on::(handlers::handle_prepare_rename) .on::(handlers::handle_rename) .on::(handlers::handle_references) - .on::(handlers::handle_formatting) - .on::(handlers::handle_range_formatting) .on::(handlers::handle_document_highlight) .on::(handlers::handle_call_hierarchy_prepare) .on::(