Skip to content

Commit 766dfcb

Browse files
authored
Merge pull request #3714 from bhcleek/debug/async-list-breakpoints
debug: handle sync breakpoints response asynchronously
2 parents 2a6b7c5 + 1949c97 commit 766dfcb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

autoload/go/debug.vim

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,18 @@ endfunction
650650
function! s:sync_breakpoints()
651651
try
652652
" get the breakpoints
653-
let l:promise = go#promise#New(function('s:rpc_response'), 20000, {})
654-
call s:call_jsonrpc(l:promise.wrapper, 'RPCServer.ListBreakpoints', {'All': v:true})
655-
let l:res = l:promise.await()
653+
call s:call_jsonrpc(function('s:handle_list_breakpoints'), 'RPCServer.ListBreakpoints', {'All': v:true})
654+
catch
655+
call go#util#EchoError(printf('failed to sync breakpoints (%s): %s', v:throwpoint, v:exception))
656+
finally
657+
endtry
658+
endfunction
659+
660+
function! s:handle_list_breakpoints(check_errors, res)
661+
try
662+
call a:check_errors()
663+
664+
let l:res = a:res
656665
if type(l:res) != v:t_dict || !has_key(l:res, 'result') || type(l:res.result) != v:t_dict || !has_key(l:res.result, 'Breakpoints')
657666
call go#util#EchoError('could not list breakpoints')
658667
endif
@@ -665,7 +674,6 @@ function! s:sync_breakpoints()
665674
" the signs with a breakpoint
666675
let l:breakpointsBySignID = {}
667676

668-
669677
" replace the sign when the id of the breakpoint and the sign are
670678
" different
671679
for l:sign in l:signs
@@ -702,7 +710,7 @@ function! s:sync_breakpoints()
702710
if empty(get(l:breakpointsBySignID, l:sign.id, ''))
703711
let l:promise = go#promise#New(function('s:rpc_response'), 20000, {})
704712
call s:call_jsonrpc(l:promise.wrapper, 'RPCServer.CreateBreakpoint', {'Breakpoint': {'file': s:substituteLocalPath(l:sign.file), 'line': l:sign.line}})
705-
let l:res = l:promise.await()
713+
"let l:res = l:promise.await()
706714
endif
707715
endfor
708716
catch
@@ -771,7 +779,6 @@ function! s:message(buf, data) abort
771779
" and
772780
" for every list you receive in a callback, all items except the first
773781
" represent newlines.
774-
call s:logger('DATA: ', '', printf('%s', a:data))
775782
let l:data = printf('%s%s', a:buf, a:data[0])
776783
for l:msg in a:data[1:]
777784
let l:data = printf("%s\n%s", l:data, l:msg)

0 commit comments

Comments
 (0)