@@ -5,7 +5,7 @@ let g:autoloaded_copilot_agent = 1
55
66scriptencoding utf- 8
77
8- let s: plugin_version = ' 1.4.0 '
8+ let s: plugin_version = ' 1.4.1 '
99
1010let s: error_exit = -1
1111
@@ -259,7 +259,12 @@ endfunction
259259
260260function ! s: OnExit (agent, code) abort
261261 let a: agent .exit_status = a: code
262- unlet ! a: agent .job
262+ if has_key (a: agent , ' job' )
263+ call remove (a: agent , ' job' )
264+ endif
265+ if has_key (a: agent , ' client_id' )
266+ call remove (a: agent , ' client_id' )
267+ endif
263268 for id in sort (keys (a: agent .requests), { a , b - > + a > + b })
264269 let request = remove (a: agent .requests, id)
265270 if request.status == # ' canceled'
@@ -284,15 +289,14 @@ function! copilot#agent#LspInit(agent_id, initialize_result) abort
284289 return
285290 endif
286291 let instance = s: instances [a: agent_id ]
287- call s: GetCapabilitiesResult (a: initialize_result , instance)
292+ call timer_start ( 0 , { _ - > s: GetCapabilitiesResult (a: initialize_result , instance)} )
288293endfunction
289294
290295function ! copilot#agent#LspExit (agent_id, code, signal) abort
291296 if ! has_key (s: instances , a: agent_id )
292297 return
293298 endif
294299 let instance = remove (s: instances , a: agent_id )
295- unlet ! instance.client_id
296300 call s: OnExit (instance, a: code )
297301endfunction
298302
@@ -305,7 +309,13 @@ endfunction
305309
306310function ! s: LspRequest (method, params, ... ) dict abort
307311 let id = v: lua .require' _copilot' .lsp_request (self .id, a: method , a: params )
308- return call (' s:SetUpRequest' , [self , id, a: method , a: params ] + a: 000 )
312+ if id isnot # v: null
313+ return call (' s:SetUpRequest' , [self , id, a: method , a: params ] + a: 000 )
314+ endif
315+ if has_key (self , ' client_id' )
316+ call copilot#agent#LspExit (self .client_id, -1 , -1 )
317+ endif
318+ throw ' copilot#agent: LSP client not available'
309319endfunction
310320
311321function ! s: LspClose () dict abort
0 commit comments