@@ -581,10 +581,7 @@ impl GlobalState {
581
581
// When we're running multiple flychecks, we have to include a disambiguator in
582
582
// the title, or the editor complains. Note that this is a user-facing string.
583
583
let title = if self . flycheck . len ( ) == 1 {
584
- match self . config . flycheck ( ) {
585
- Some ( config) => format ! ( "{}" , config) ,
586
- None => "cargo check" . to_string ( ) ,
587
- }
584
+ format ! ( "{}" , self . config. flycheck( ) )
588
585
} else {
589
586
format ! ( "cargo check (#{})" , id + 1 )
590
587
} ;
@@ -593,7 +590,7 @@ impl GlobalState {
593
590
state,
594
591
message,
595
592
None ,
596
- Some ( format ! ( "rust-analyzer/checkOnSave /{}" , id) ) ,
593
+ Some ( format ! ( "rust-analyzer/flycheck /{}" , id) ) ,
597
594
) ;
598
595
}
599
596
}
@@ -638,7 +635,6 @@ impl GlobalState {
638
635
. on_sync_mut :: < lsp_ext:: ReloadWorkspace > ( handlers:: handle_workspace_reload)
639
636
. on_sync_mut :: < lsp_ext:: MemoryUsage > ( handlers:: handle_memory_usage)
640
637
. on_sync_mut :: < lsp_ext:: ShuffleCrateGraph > ( handlers:: handle_shuffle_crate_graph)
641
- . on_sync_mut :: < lsp_ext:: CancelFlycheck > ( handlers:: handle_cancel_flycheck)
642
638
. on_sync :: < lsp_ext:: JoinLines > ( handlers:: handle_join_lines)
643
639
. on_sync :: < lsp_ext:: OnEnter > ( handlers:: handle_on_enter)
644
640
. on_sync :: < lsp_types:: request:: SelectionRangeRequest > ( handlers:: handle_selection_range)
@@ -796,7 +792,7 @@ impl GlobalState {
796
792
} ) ?
797
793
. on :: < lsp_types:: notification:: WorkDoneProgressCancel > ( |this, params| {
798
794
if let lsp_types:: NumberOrString :: String ( s) = & params. token {
799
- if let Some ( id) = s. strip_prefix ( "rust-analyzer/checkOnSave /" ) {
795
+ if let Some ( id) = s. strip_prefix ( "rust-analyzer/flycheck /" ) {
800
796
if let Ok ( id) = u32:: from_str_radix ( id, 10 ) {
801
797
if let Some ( flycheck) = this. flycheck . get ( id as usize ) {
802
798
flycheck. cancel ( ) ;
@@ -825,6 +821,7 @@ impl GlobalState {
825
821
}
826
822
Ok ( ( ) )
827
823
} ) ?
824
+ . on :: < lsp_ext:: CancelFlycheck > ( handlers:: handle_cancel_flycheck) ?
828
825
. on :: < lsp_types:: notification:: DidChangeTextDocument > ( |this, params| {
829
826
if let Ok ( path) = from_proto:: vfs_path ( & params. text_document . uri ) {
830
827
match this. mem_docs . get_mut ( & path) {
@@ -864,6 +861,10 @@ impl GlobalState {
864
861
}
865
862
Ok ( ( ) )
866
863
} ) ?
864
+ . on :: < lsp_ext:: ClearFlycheck > ( |this, ( ) | {
865
+ this. diagnostics . clear_check_all ( ) ;
866
+ Ok ( ( ) )
867
+ } ) ?
867
868
. on :: < lsp_ext:: RunFlycheck > ( |this, params| {
868
869
if let Some ( text_document) = params. text_document {
869
870
if let Ok ( vfs_path) = from_proto:: vfs_path ( & text_document. uri ) {
@@ -888,14 +889,14 @@ impl GlobalState {
888
889
}
889
890
}
890
891
891
- if run_flycheck ( this, vfs_path) {
892
+ if !this . config . check_on_save ( ) || run_flycheck ( this, vfs_path) {
892
893
return Ok ( ( ) ) ;
893
894
}
894
- }
895
-
896
- // No specific flycheck was triggered, so let's trigger all of them.
897
- for flycheck in this . flycheck . iter ( ) {
898
- flycheck . restart ( ) ;
895
+ } else if this . config . check_on_save ( ) {
896
+ // No specific flycheck was triggered, so let's trigger all of them.
897
+ for flycheck in this . flycheck . iter ( ) {
898
+ flycheck. restart ( ) ;
899
+ }
899
900
}
900
901
Ok ( ( ) )
901
902
} ) ?
0 commit comments