@@ -162,7 +162,9 @@ function! s:update_breakpoint(res) abort
162
162
endif
163
163
silent ! exe ' norm!' linenr .' G'
164
164
silent ! normal ! zvzz
165
+ " TODO(bc): convert to use s:sign_unplace()
165
166
silent ! sign unplace 9999
167
+ " TODO(bc): convert to use s:sign_place()
166
168
silent ! exe ' sign place 9999 line=' . linenr . ' name=godebugcurline file=' . filename
167
169
endfunction
168
170
@@ -553,9 +555,8 @@ function! s:out_cb(ch, msg) abort
553
555
let s: state [' ready' ] = 1
554
556
555
557
" replace all the breakpoints set before delve started so that the ids won't overlap.
556
- let l: breakpoints = s: list_breakpoints ()
557
558
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 )
559
560
call go#debug#Breakpoint (l: bt .line , l: bt .file )
560
561
endfor
561
562
@@ -1103,21 +1104,19 @@ function! go#debug#Breakpoint(...) abort
1103
1104
endfor
1104
1105
1105
1106
" Remove breakpoint.
1106
- " TODO(bc): use sign_unplace() when it's available
1107
1107
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 )
1109
1109
if s: isActive ()
1110
1110
let res = s: call_jsonrpc (' RPCServer.ClearBreakpoint' , {' id' : l: found .id})
1111
1111
endif
1112
1112
else " Add breakpoint
1113
- " TODO(bc): use sign_placelist() when it's available.
1114
1113
if s: isActive ()
1115
1114
let l: res = s: call_jsonrpc (' RPCServer.CreateBreakpoint' , {' Breakpoint' : {' file' : l: filename , ' line' : l: linenr }})
1116
1115
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 )
1118
1117
else
1119
1118
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 )
1121
1120
endif
1122
1121
endif
1123
1122
catch
@@ -1128,6 +1127,24 @@ function! go#debug#Breakpoint(...) abort
1128
1127
return 0
1129
1128
endfunction
1130
1129
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
+
1131
1148
function ! s: list_breakpoints ()
1132
1149
let l: breakpoints = []
1133
1150
let l: signs = s: sign_getplaced ()
@@ -1193,7 +1210,23 @@ function! s:sign_getplaced() abort
1193
1210
return l: signs
1194
1211
endif
1195
1212
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
1197
1230
endfunction
1198
1231
1199
1232
exe ' sign define godebugbreakpoint text=' .go#config#DebugBreakpointSignText ().' texthl=GoDebugBreakpoint'
0 commit comments