@@ -162,7 +162,9 @@ function! s:update_breakpoint(res) abort
162162 endif
163163 silent ! exe ' norm!' linenr .' G'
164164 silent ! normal ! zvzz
165+ " TODO(bc): convert to use s:sign_unplace()
165166 silent ! sign unplace 9999
167+ " TODO(bc): convert to use s:sign_place()
166168 silent ! exe ' sign place 9999 line=' . linenr . ' name=godebugcurline file=' . filename
167169endfunction
168170
@@ -553,9 +555,8 @@ function! s:out_cb(ch, msg) abort
553555 let s: state [' ready' ] = 1
554556
555557 " replace all the breakpoints set before delve started so that the ids won't overlap.
556- let l: breakpoints = s: list_breakpoints ()
557558 for l: bt in s: list_breakpoints ()
558- exe ' sign unplace ' . l: bt .id
559+ call s: sign_unplace ( l: bt .id, l: bt .file )
559560 call go#debug#Breakpoint (l: bt .line , l: bt .file )
560561 endfor
561562
@@ -1103,21 +1104,19 @@ function! go#debug#Breakpoint(...) abort
11031104 endfor
11041105
11051106 " Remove breakpoint.
1106- " TODO(bc): use sign_unplace() when it's available
11071107 if type (l: found ) == v: t_dict && ! empty (l: found )
1108- exe ' sign unplace ' . l: found .id . ' file= ' . l: found .file
1108+ call s: sign_unplace ( l: found .id, l: found .file )
11091109 if s: isActive ()
11101110 let res = s: call_jsonrpc (' RPCServer.ClearBreakpoint' , {' id' : l: found .id})
11111111 endif
11121112 else " Add breakpoint
1113- " TODO(bc): use sign_placelist() when it's available.
11141113 if s: isActive ()
11151114 let l: res = s: call_jsonrpc (' RPCServer.CreateBreakpoint' , {' Breakpoint' : {' file' : l: filename , ' line' : l: linenr }})
11161115 let l: bt = res .result.Breakpoint
1117- exe ' sign place ' . l: bt .id . ' line= ' . l: bt .line . ' name=godebugbreakpoint file= ' . l: bt .file
1116+ call s: sign_place ( l: bt .id, l: bt .file , l: bt .line )
11181117 else
11191118 let l: id = len (s: list_breakpoints ()) + 1
1120- exe ' sign place ' . l: id . ' line= ' . l: linenr . ' name=godebugbreakpoint file= ' . l: filename
1119+ call s: sign_place ( l: id, l: filename , l: linenr )
11211120 endif
11221121 endif
11231122 catch
@@ -1128,6 +1127,24 @@ function! go#debug#Breakpoint(...) abort
11281127 return 0
11291128endfunction
11301129
1130+ function ! s: sign_unplace (id, file ) abort
1131+ if ! exists (' *sign_unplace' )
1132+ exe ' sign unplace ' . a: id .' file=' . a: file
1133+ return
1134+ endif
1135+
1136+ call sign_unplace (' vim-go-debug' , {' buffer' : a: file , ' id' : a: id })
1137+ endfunction
1138+
1139+ function ! s: sign_place (id, expr , lnum) abort
1140+ if ! exists (' *sign_place' )
1141+ exe ' sign place ' . a: id . ' line=' . a: lnum . ' name=godebugbreakpoint file=' . a: expr
1142+ return
1143+ endif
1144+
1145+ call sign_place (a: id , ' vim-go-debug' , ' godebugbreakpoint' , a: expr , {' lnum' : a: lnum })
1146+ endfunction
1147+
11311148function ! s: list_breakpoints ()
11321149 let l: breakpoints = []
11331150 let l: signs = s: sign_getplaced ()
@@ -1193,7 +1210,23 @@ function! s:sign_getplaced() abort
11931210 return l: signs
11941211 endif
11951212
1196- return sign_getplaced ()
1213+
1214+ " it would be nice to use lambda's here, but vim-vimparser currently fails
1215+ " to parse lamdas as map() arguments.
1216+ " TODO(bc): return flatten(map(filter(copy(getbufinfo()), { _, val -> val.listed }), { _, val -> sign_getplaced(val.bufnr, {'group': 'vim-go-debug', 'name': 'godebugbreakpoint'})}))
1217+ let l: bufinfo = getbufinfo ()
1218+ let l: listed = []
1219+ for l: info in l: bufinfo
1220+ if l: info .listed
1221+ let l: listed = add (l: listed , l: info )
1222+ endif
1223+ endfor
1224+
1225+ let l: signs = []
1226+ for l: buf in l: listed
1227+ let l: signs = add (l: signs , sign_getplaced (l: buf .bufnr , {' group' : ' vim-go-debug' , ' name' : ' godebugbreakpoint' })[0 ])
1228+ endfor
1229+ return l: signs
11971230endfunction
11981231
11991232exe ' sign define godebugbreakpoint text=' .go#config#DebugBreakpointSignText ().' texthl=GoDebugBreakpoint'
0 commit comments