@@ -91,7 +91,8 @@ def start
9191 # The following requests need to be executed in the main thread directly to avoid concurrency issues. Everything
9292 # else is pushed into the incoming queue
9393 case method
94- when "initialize" , "initialized" , "textDocument/didOpen" , "textDocument/didClose" , "textDocument/didChange"
94+ when "initialize" , "initialized" , "textDocument/didOpen" , "textDocument/didClose" , "textDocument/didChange" ,
95+ "$/cancelRequest"
9596 process_message ( message )
9697 when "shutdown"
9798 send_log_message ( "Shutting down Ruby LSP..." )
@@ -133,6 +134,12 @@ def pop_response
133134 @outgoing_queue . pop
134135 end
135136
137+ # This method is only intended to be used in tests! Pushes a message to the incoming queue directly
138+ sig { params ( message : T ::Hash [ Symbol , T . untyped ] ) . void }
139+ def push_message ( message )
140+ @incoming_queue << message
141+ end
142+
136143 sig { abstract . params ( message : T ::Hash [ Symbol , T . untyped ] ) . void }
137144 def process_message ( message ) ; end
138145
@@ -154,7 +161,11 @@ def new_worker
154161 # Check if the request was cancelled before trying to process it
155162 @mutex . synchronize do
156163 if id && @cancelled_requests . include? ( id )
157- send_message ( Result . new ( id : id , response : nil ) )
164+ send_message ( Error . new (
165+ id : id ,
166+ code : Constant ::ErrorCodes ::REQUEST_CANCELLED ,
167+ message : "Request #{ id } was cancelled" ,
168+ ) )
158169 @cancelled_requests . delete ( id )
159170 next
160171 end
0 commit comments