@@ -581,10 +581,7 @@ impl GlobalState {
581581 // When we're running multiple flychecks, we have to include a disambiguator in
582582 // the title, or the editor complains. Note that this is a user-facing string.
583583 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( ) )
588585 } else {
589586 format ! ( "cargo check (#{})" , id + 1 )
590587 } ;
@@ -593,7 +590,7 @@ impl GlobalState {
593590 state,
594591 message,
595592 None ,
596- Some ( format ! ( "rust-analyzer/checkOnSave /{}" , id) ) ,
593+ Some ( format ! ( "rust-analyzer/flycheck /{}" , id) ) ,
597594 ) ;
598595 }
599596 }
@@ -638,7 +635,6 @@ impl GlobalState {
638635 . on_sync_mut :: < lsp_ext:: ReloadWorkspace > ( handlers:: handle_workspace_reload)
639636 . on_sync_mut :: < lsp_ext:: MemoryUsage > ( handlers:: handle_memory_usage)
640637 . on_sync_mut :: < lsp_ext:: ShuffleCrateGraph > ( handlers:: handle_shuffle_crate_graph)
641- . on_sync_mut :: < lsp_ext:: CancelFlycheck > ( handlers:: handle_cancel_flycheck)
642638 . on_sync :: < lsp_ext:: JoinLines > ( handlers:: handle_join_lines)
643639 . on_sync :: < lsp_ext:: OnEnter > ( handlers:: handle_on_enter)
644640 . on_sync :: < lsp_types:: request:: SelectionRangeRequest > ( handlers:: handle_selection_range)
@@ -796,7 +792,7 @@ impl GlobalState {
796792 } ) ?
797793 . on :: < lsp_types:: notification:: WorkDoneProgressCancel > ( |this, params| {
798794 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 /" ) {
800796 if let Ok ( id) = u32:: from_str_radix ( id, 10 ) {
801797 if let Some ( flycheck) = this. flycheck . get ( id as usize ) {
802798 flycheck. cancel ( ) ;
@@ -825,6 +821,7 @@ impl GlobalState {
825821 }
826822 Ok ( ( ) )
827823 } ) ?
824+ . on :: < lsp_ext:: CancelFlycheck > ( handlers:: handle_cancel_flycheck) ?
828825 . on :: < lsp_types:: notification:: DidChangeTextDocument > ( |this, params| {
829826 if let Ok ( path) = from_proto:: vfs_path ( & params. text_document . uri ) {
830827 match this. mem_docs . get_mut ( & path) {
@@ -864,6 +861,10 @@ impl GlobalState {
864861 }
865862 Ok ( ( ) )
866863 } ) ?
864+ . on :: < lsp_ext:: ClearFlycheck > ( |this, ( ) | {
865+ this. diagnostics . clear_check_all ( ) ;
866+ Ok ( ( ) )
867+ } ) ?
867868 . on :: < lsp_ext:: RunFlycheck > ( |this, params| {
868869 if let Some ( text_document) = params. text_document {
869870 if let Ok ( vfs_path) = from_proto:: vfs_path ( & text_document. uri ) {
@@ -888,14 +889,14 @@ impl GlobalState {
888889 }
889890 }
890891
891- if run_flycheck ( this, vfs_path) {
892+ if !this . config . check_on_save ( ) || run_flycheck ( this, vfs_path) {
892893 return Ok ( ( ) ) ;
893894 }
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+ }
899900 }
900901 Ok ( ( ) )
901902 } ) ?
0 commit comments