Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6b46095

Browse files
committed
Make formatting a latency-sensitive request
1 parent 74bc2a4 commit 6b46095

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,14 @@ impl GlobalState {
695695
.on_latency_sensitive::<lsp_types::request::SemanticTokensRangeRequest>(
696696
handlers::handle_semantic_tokens_range,
697697
)
698+
// Formatting is not caused by the user typing,
699+
// but it does qualify as latency-sensitive
700+
// because a delay before formatting is applied
701+
// can be confusing for the user.
702+
.on_latency_sensitive::<lsp_types::request::Formatting>(handlers::handle_formatting)
703+
.on_latency_sensitive::<lsp_types::request::RangeFormatting>(
704+
handlers::handle_range_formatting,
705+
)
698706
// All other request handlers
699707
.on::<lsp_ext::FetchDependencyList>(handlers::fetch_dependency_list)
700708
.on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)
@@ -730,8 +738,6 @@ impl GlobalState {
730738
.on::<lsp_types::request::PrepareRenameRequest>(handlers::handle_prepare_rename)
731739
.on::<lsp_types::request::Rename>(handlers::handle_rename)
732740
.on::<lsp_types::request::References>(handlers::handle_references)
733-
.on::<lsp_types::request::Formatting>(handlers::handle_formatting)
734-
.on::<lsp_types::request::RangeFormatting>(handlers::handle_range_formatting)
735741
.on::<lsp_types::request::DocumentHighlightRequest>(handlers::handle_document_highlight)
736742
.on::<lsp_types::request::CallHierarchyPrepare>(handlers::handle_call_hierarchy_prepare)
737743
.on::<lsp_types::request::CallHierarchyIncomingCalls>(

0 commit comments

Comments
 (0)