@@ -652,14 +652,20 @@ impl GlobalState {
652
652
use crate :: handlers:: request as handlers;
653
653
654
654
dispatcher
655
+ // Request handlers that must run on the main thread
656
+ // because they mutate GlobalState:
655
657
. on_sync_mut :: < lsp_ext:: ReloadWorkspace > ( handlers:: handle_workspace_reload)
656
658
. on_sync_mut :: < lsp_ext:: RebuildProcMacros > ( handlers:: handle_proc_macros_rebuild)
657
659
. on_sync_mut :: < lsp_ext:: MemoryUsage > ( handlers:: handle_memory_usage)
658
660
. on_sync_mut :: < lsp_ext:: ShuffleCrateGraph > ( handlers:: handle_shuffle_crate_graph)
661
+ // Request handlers which are related to the user typing
662
+ // are run on the main thread to reduce latency:
659
663
. on_sync :: < lsp_ext:: JoinLines > ( handlers:: handle_join_lines)
660
664
. on_sync :: < lsp_ext:: OnEnter > ( handlers:: handle_on_enter)
661
665
. on_sync :: < lsp_types:: request:: SelectionRangeRequest > ( handlers:: handle_selection_range)
662
666
. on_sync :: < lsp_ext:: MatchingBrace > ( handlers:: handle_matching_brace)
667
+ . on_sync :: < lsp_ext:: OnTypeFormatting > ( handlers:: handle_on_type_formatting)
668
+ // All other request handlers:
663
669
. on :: < lsp_ext:: FetchDependencyList > ( handlers:: fetch_dependency_list)
664
670
. on :: < lsp_ext:: AnalyzerStatus > ( handlers:: handle_analyzer_status)
665
671
. on :: < lsp_ext:: SyntaxTree > ( handlers:: handle_syntax_tree)
@@ -680,7 +686,6 @@ impl GlobalState {
680
686
. on :: < lsp_ext:: OpenCargoToml > ( handlers:: handle_open_cargo_toml)
681
687
. on :: < lsp_ext:: MoveItem > ( handlers:: handle_move_item)
682
688
. on :: < lsp_ext:: WorkspaceSymbol > ( handlers:: handle_workspace_symbol)
683
- . on :: < lsp_ext:: OnTypeFormatting > ( handlers:: handle_on_type_formatting)
684
689
. on :: < lsp_types:: request:: DocumentSymbolRequest > ( handlers:: handle_document_symbol)
685
690
. on :: < lsp_types:: request:: GotoDefinition > ( handlers:: handle_goto_definition)
686
691
. on :: < lsp_types:: request:: GotoDeclaration > ( handlers:: handle_goto_declaration)
0 commit comments