@@ -325,7 +325,7 @@ function! s:GetSuggestionsCycling(callback) abort
325325 elseif exists (' b:_copilot.suggestions' )
326326 let b: _copilot .cycling_callbacks = [a: callback ]
327327 let b: _copilot .cycling = copilot#Request (' getCompletionsCycling' ,
328- \ params,
328+ \ b: _copilot . first . params,
329329 \ function (' s:GetSuggestionsCyclingCallback' , [b: _copilot ]),
330330 \ function (' s:GetSuggestionsCyclingCallback' , [b: _copilot ]),
331331 \ )
@@ -587,6 +587,10 @@ function! s:DevicePoll(result, login_data, timer) abort
587587 \ function (' s:DeviceResponse' , [a: result , a: login_data ]))
588588endfunction
589589
590+ function ! s: BrowserCallback (into, code) abort
591+ let a: into .code = a: code
592+ endfunction
593+
590594function ! copilot#Browser () abort
591595 if type (get (g: , ' copilot_browser' )) == v: t_list
592596 return copy (g: copilot_browser )
@@ -731,8 +735,13 @@ function! s:commands.setup(opts) abort
731735 while c isnot # 13 && c isnot # 10 && c isnot # 0
732736 let c = getchar ()
733737 endwhile
734- let exit_status = copilot#job#Stream (browser + [data.verification_uri], v: null , v: null )
735- if exit_status
738+ let status = {}
739+ call copilot#job#Stream (browser + [data.verification_uri], v: null , v: null , function (' s:BrowserCallback' , [status]))
740+ let time = reltime ()
741+ while empty (status) && reltimefloat (reltime (time)) < 5
742+ sleep 10 m
743+ endwhile
744+ if get (status, ' code' , browser[0 ] !=# ' xdg-open' ) != 0
736745 echo " Failed to open browser. Visit " . data.verification_uri
737746 else
738747 echo " Opened " . data.verification_uri
0 commit comments