diff options
| author | Luna Razzaghipour <lunarazzaghipour@gmail.com> | 2023-05-28 22:10:24 +1000 |
|---|---|---|
| committer | Luna Razzaghipour <lunarazzaghipour@gmail.com> | 2023-05-28 22:10:24 +1000 |
| commit | 6b46095980bf73512f5ed06d0659d263a4c990df (patch) | |
| tree | bd3283d3fef691e3bf41b07f8cd0a520861aaa39 | |
| parent | 74bc2a47e09cbfa1f52479c083c0a0d4d502dbce (diff) | |
| download | rust-6b46095980bf73512f5ed06d0659d263a4c990df.tar.gz rust-6b46095980bf73512f5ed06d0659d263a4c990df.zip | |
Make formatting a latency-sensitive request
| -rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 10 |
1 files 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 @@ impl GlobalState { .on_latency_sensitive::<lsp_types::request::SemanticTokensRangeRequest>( 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::<lsp_types::request::Formatting>(handlers::handle_formatting) + .on_latency_sensitive::<lsp_types::request::RangeFormatting>( + handlers::handle_range_formatting, + ) // All other request handlers .on::<lsp_ext::FetchDependencyList>(handlers::fetch_dependency_list) .on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status) @@ -730,8 +738,6 @@ impl GlobalState { .on::<lsp_types::request::PrepareRenameRequest>(handlers::handle_prepare_rename) .on::<lsp_types::request::Rename>(handlers::handle_rename) .on::<lsp_types::request::References>(handlers::handle_references) - .on::<lsp_types::request::Formatting>(handlers::handle_formatting) - .on::<lsp_types::request::RangeFormatting>(handlers::handle_range_formatting) .on::<lsp_types::request::DocumentHighlightRequest>(handlers::handle_document_highlight) .on::<lsp_types::request::CallHierarchyPrepare>(handlers::handle_call_hierarchy_prepare) .on::<lsp_types::request::CallHierarchyIncomingCalls>( |
