Skip to content

Commit de46460

Browse files
committed
Make percentage optional when starting progress notifications
1 parent 3a2070a commit de46460

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/ruby_lsp/server.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,8 @@ def perform_initial_indexing
12091209
end_progress("indexing-progress")
12101210
end
12111211

1212-
#: (String id, String title, ?percentage: Integer) -> void
1213-
def begin_progress(id, title, percentage: 0)
1212+
#: (String id, String title, ?percentage: Integer?, ?message: String?) -> void
1213+
def begin_progress(id, title, percentage: nil, message: nil)
12141214
return unless @global_state.client_capabilities.supports_progress
12151215

12161216
send_message(Request.new(
@@ -1219,7 +1219,10 @@ def begin_progress(id, title, percentage: 0)
12191219
params: Interface::WorkDoneProgressCreateParams.new(token: id),
12201220
))
12211221

1222-
send_message(Notification.progress_begin(id, title, percentage: percentage, message: "#{percentage}% completed"))
1222+
# Omitting the percentage tells the client to show indefinite progress. Only fabricate a "% completed" message
1223+
# when a caller reports incremental percentages and didn't provide an explicit message
1224+
message ||= "#{percentage}% completed" if percentage
1225+
send_message(Notification.progress_begin(id, title, percentage: percentage, message: message))
12231226
end
12241227

12251228
#: (String, ?message: String?, ?percentage: Integer?) -> void

0 commit comments

Comments
 (0)