Skip to content

Commit d421abe

Browse files
authored
Refresh diagnostics on .rubocop_todo.yml change (#3800)
1 parent a826b1d commit d421abe

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

lib/ruby_lsp/server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def run_initialize(message)
303303
@current_request_id,
304304
Interface::RelativePattern.new(
305305
base_uri: @global_state.workspace_uri.to_s,
306-
pattern: "{.rubocop.yml,.rubocop}",
306+
pattern: "{.rubocop.yml,.rubocop,.rubocop_todo.yml}",
307307
),
308308
registration_id: "rubocop-watcher",
309309
))
@@ -1045,7 +1045,7 @@ def workspace_did_change_watched_files(message)
10451045

10461046
file_name = File.basename(file_path)
10471047

1048-
if file_name == ".rubocop.yml" || file_name == ".rubocop"
1048+
if file_name == ".rubocop.yml" || file_name == ".rubocop" || file_name == ".rubocop_todo.yml"
10491049
handle_rubocop_config_change(uri)
10501050
end
10511051
end

test/server_test.rb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,6 @@ def test_edits_outside_of_declarations_do_not_trigger_indexing
10581058
end
10591059

10601060
def test_rubocop_config_changes_trigger_workspace_diagnostic_refresh
1061-
uri = URI::Generic.from_path(path: File.join(Dir.pwd, ".rubocop.yml"))
1062-
10631061
@server.process_message({
10641062
id: 1,
10651063
method: "initialize",
@@ -1073,22 +1071,26 @@ def test_rubocop_config_changes_trigger_workspace_diagnostic_refresh
10731071
},
10741072
},
10751073
})
1076-
10771074
@server.global_state.index.index_all(uris: [])
1078-
@server.process_message({
1079-
method: "workspace/didChangeWatchedFiles",
1080-
params: {
1081-
changes: [
1082-
{
1083-
uri: uri,
1084-
type: RubyLsp::Constant::FileChangeType::CHANGED,
1085-
},
1086-
],
1087-
},
1088-
})
10891075

1090-
request = find_message(RubyLsp::Request)
1091-
assert_equal("workspace/diagnostic/refresh", request.method)
1076+
[".rubocop.yml", ".rubocop", ".rubocop_todo.yml"].each do |config_file|
1077+
uri = URI::Generic.from_path(path: File.join(Dir.pwd, config_file))
1078+
1079+
@server.process_message({
1080+
method: "workspace/didChangeWatchedFiles",
1081+
params: {
1082+
changes: [
1083+
{
1084+
uri: uri,
1085+
type: RubyLsp::Constant::FileChangeType::CHANGED,
1086+
},
1087+
],
1088+
},
1089+
})
1090+
1091+
request = find_message(RubyLsp::Request)
1092+
assert_equal("workspace/diagnostic/refresh", request.method)
1093+
end
10921094
end
10931095

10941096
def test_compose_bundle_creates_file_to_skip_next_compose

0 commit comments

Comments
 (0)