@@ -502,6 +502,10 @@ def test_changed_file_only_indexes_ruby
502
502
uri : URI ( "file:///.rubocop.yml" ) ,
503
503
type : RubyLsp ::Constant ::FileChangeType ::CREATED ,
504
504
} ,
505
+ {
506
+ uri : URI ( "file:///.rubocop_todo.yml" ) ,
507
+ type : RubyLsp ::Constant ::FileChangeType ::CREATED ,
508
+ } ,
505
509
] ,
506
510
} ,
507
511
} )
@@ -619,23 +623,11 @@ def version
619
623
end
620
624
621
625
def test_did_change_watched_files_processes_unique_change_entries
622
- @server . global_state . index . index_all ( uris : [ ] )
623
- @server . expects ( :handle_rubocop_config_change ) . once
624
- @server . process_message ( {
625
- method : "workspace/didChangeWatchedFiles" ,
626
- params : {
627
- changes : [
628
- {
629
- uri : URI ::Generic . from_path ( path : File . join ( Dir . pwd , ".rubocop.yml" ) ) . to_s ,
630
- type : RubyLsp ::Constant ::FileChangeType ::CHANGED ,
631
- } ,
632
- {
633
- uri : URI ::Generic . from_path ( path : File . join ( Dir . pwd , ".rubocop.yml" ) ) . to_s ,
634
- type : RubyLsp ::Constant ::FileChangeType ::CHANGED ,
635
- } ,
636
- ] ,
637
- } ,
638
- } )
626
+ assert_rubocop_config_handles_unique_change_entries ( ".rubocop.yml" )
627
+ end
628
+
629
+ def test_did_change_watched_files_processes_unique_change_entries_for_rubocop_todo
630
+ assert_rubocop_config_handles_unique_change_entries ( ".rubocop_todo.yml" )
639
631
end
640
632
641
633
def test_workspace_addons
@@ -1123,37 +1115,11 @@ def test_edits_outside_of_declarations_do_not_trigger_indexing
1123
1115
end
1124
1116
1125
1117
def test_rubocop_config_changes_trigger_workspace_diagnostic_refresh
1126
- uri = URI ::Generic . from_path ( path : File . join ( Dir . pwd , ".rubocop.yml" ) )
1127
-
1128
- @server . process_message ( {
1129
- id : 1 ,
1130
- method : "initialize" ,
1131
- params : {
1132
- initializationOptions : { } ,
1133
- capabilities : {
1134
- general : {
1135
- positionEncodings : [ "utf-8" ] ,
1136
- } ,
1137
- workspace : { diagnostics : { refreshSupport : true } } ,
1138
- } ,
1139
- } ,
1140
- } )
1141
-
1142
- @server . global_state . index . index_all ( uris : [ ] )
1143
- @server . process_message ( {
1144
- method : "workspace/didChangeWatchedFiles" ,
1145
- params : {
1146
- changes : [
1147
- {
1148
- uri : uri ,
1149
- type : RubyLsp ::Constant ::FileChangeType ::CHANGED ,
1150
- } ,
1151
- ] ,
1152
- } ,
1153
- } )
1118
+ assert_rubocop_config_triggers_diagnostic_refresh ( ".rubocop.yml" )
1119
+ end
1154
1120
1155
- request = find_message ( RubyLsp :: Request )
1156
- assert_equal ( "workspace/diagnostic/refresh" , request . method )
1121
+ def test_rubocop_todo_config_changes_trigger_workspace_diagnostic_refresh
1122
+ assert_rubocop_config_triggers_diagnostic_refresh ( ".rubocop_todo.yml" )
1157
1123
end
1158
1124
1159
1125
def test_compose_bundle_creates_file_to_skip_next_compose
@@ -1712,6 +1678,58 @@ def deactivate; end
1712
1678
end
1713
1679
end
1714
1680
1681
+ def assert_rubocop_config_handles_unique_change_entries ( config_file )
1682
+ @server . global_state . index . index_all ( uris : [ ] )
1683
+ @server . expects ( :handle_rubocop_config_change ) . once
1684
+ @server . process_message ( {
1685
+ method : "workspace/didChangeWatchedFiles" ,
1686
+ params : {
1687
+ changes : [
1688
+ {
1689
+ uri : URI ::Generic . from_path ( path : File . join ( Dir . pwd , config_file ) ) . to_s ,
1690
+ type : RubyLsp ::Constant ::FileChangeType ::CHANGED ,
1691
+ } ,
1692
+ {
1693
+ uri : URI ::Generic . from_path ( path : File . join ( Dir . pwd , config_file ) ) . to_s ,
1694
+ type : RubyLsp ::Constant ::FileChangeType ::CHANGED ,
1695
+ } ,
1696
+ ] ,
1697
+ } ,
1698
+ } )
1699
+ end
1700
+
1701
+ def assert_rubocop_config_triggers_diagnostic_refresh ( config_file )
1702
+ @server . process_message ( {
1703
+ id : 1 ,
1704
+ method : "initialize" ,
1705
+ params : {
1706
+ initializationOptions : { } ,
1707
+ capabilities : {
1708
+ general : {
1709
+ positionEncodings : [ "utf-8" ] ,
1710
+ } ,
1711
+ workspace : { diagnostics : { refreshSupport : true } } ,
1712
+ } ,
1713
+ } ,
1714
+ } )
1715
+
1716
+ @server . global_state . index . index_all ( uris : [ ] )
1717
+ @server . process_message ( {
1718
+ method : "workspace/didChangeWatchedFiles" ,
1719
+ params : {
1720
+ changes : [
1721
+ {
1722
+ uri : URI ::Generic . from_path ( path : File . join ( Dir . pwd , config_file ) ) . to_s ,
1723
+ type : RubyLsp ::Constant ::FileChangeType ::CHANGED ,
1724
+ } ,
1725
+ ] ,
1726
+ } ,
1727
+ } )
1728
+
1729
+ request = find_message ( RubyLsp ::Request )
1730
+ assert_equal ( "workspace/diagnostic/refresh" , request . method )
1731
+ end
1732
+
1715
1733
#: (Class desired_class, ?String? desired_method, ?id: Integer?) -> untyped
1716
1734
def find_message ( desired_class , desired_method = nil , id : nil )
1717
1735
message = @server . pop_response
0 commit comments