Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ruby_lsp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def run_initialize(message)
@current_request_id,
Interface::RelativePattern.new(
base_uri: @global_state.workspace_uri.to_s,
pattern: "{.rubocop.yml,.rubocop}",
pattern: "{.rubocop.yml,.rubocop,.rubocop_todo.yml}",
),
registration_id: "rubocop-watcher",
))
Expand Down Expand Up @@ -1045,7 +1045,7 @@ def workspace_did_change_watched_files(message)

file_name = File.basename(file_path)

if file_name == ".rubocop.yml" || file_name == ".rubocop"
if file_name == ".rubocop.yml" || file_name == ".rubocop" || file_name == ".rubocop_todo.yml"
handle_rubocop_config_change(uri)
end
end
Expand Down
34 changes: 18 additions & 16 deletions test/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,6 @@ def test_edits_outside_of_declarations_do_not_trigger_indexing
end

def test_rubocop_config_changes_trigger_workspace_diagnostic_refresh
uri = URI::Generic.from_path(path: File.join(Dir.pwd, ".rubocop.yml"))

@server.process_message({
id: 1,
method: "initialize",
Expand All @@ -1073,22 +1071,26 @@ def test_rubocop_config_changes_trigger_workspace_diagnostic_refresh
},
},
})

@server.global_state.index.index_all(uris: [])
@server.process_message({
method: "workspace/didChangeWatchedFiles",
params: {
changes: [
{
uri: uri,
type: RubyLsp::Constant::FileChangeType::CHANGED,
},
],
},
})

request = find_message(RubyLsp::Request)
assert_equal("workspace/diagnostic/refresh", request.method)
[".rubocop.yml", ".rubocop", ".rubocop_todo.yml"].each do |config_file|
uri = URI::Generic.from_path(path: File.join(Dir.pwd, config_file))

@server.process_message({
method: "workspace/didChangeWatchedFiles",
params: {
changes: [
{
uri: uri,
type: RubyLsp::Constant::FileChangeType::CHANGED,
},
],
},
})

request = find_message(RubyLsp::Request)
assert_equal("workspace/diagnostic/refresh", request.method)
end
end

def test_compose_bundle_creates_file_to_skip_next_compose
Expand Down