Skip to content

Commit 8a6d484

Browse files
committed
Add F9 mapping to set breakpoints on stacktrace
1 parent 2f60cb8 commit 8a6d484

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

autoload/OmniSharp/testrunner.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,29 @@ function! s:Paint() abort
241241
endfunction
242242

243243

244+
function! OmniSharp#testrunner#SetBreakpoints() abort
245+
if !OmniSharp#util#HasVimspector()
246+
echohl WarningMsg
247+
echomsg 'Vimspector required to set breakpoints'
248+
echohl None
249+
return
250+
endif
251+
let test = s:utils.findTest()
252+
if !has_key(test, 'stacktrace')
253+
echo 'No breakpoints added'
254+
return
255+
endif
256+
let bps = filter(copy(test.stacktrace),
257+
\ "has_key(v:val, 'filename') && has_key(v:val, 'lnum')")
258+
for bp in bps
259+
call vimspector#SetLineBreakpoint(bp.filename, bp.lnum)
260+
endfor
261+
let n = len(bps)
262+
let message = printf('%d break point%s set', n, n == 1 ? '' : 's')
263+
echomsg message
264+
endfunction
265+
266+
244267
function! OmniSharp#testrunner#SetTests(bufferTests) abort
245268
let winid = win_getid()
246269
for buffer in a:bufferTests

ftplugin/omnisharptest/OmniSharp.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set signcolumn=no
99
nnoremap <buffer> <Plug>(omnisharp_testrunner_togglebanner) :call OmniSharp#testrunner#ToggleBanner()<CR>
1010
nnoremap <buffer> <Plug>(omnisharp_testrunner_run) :call OmniSharp#testrunner#Run()<CR>
1111
nnoremap <buffer> <Plug>(omnisharp_testrunner_debug) :call OmniSharp#testrunner#Debug()<CR>
12+
nnoremap <buffer> <Plug>(omnisharp_testrunner_set_breakpoints) :call OmniSharp#testrunner#SetBreakpoints()<CR>
1213
nnoremap <buffer> <Plug>(omnisharp_testrunner_navigate) :call OmniSharp#testrunner#Navigate()<CR>
1314
1415
function! s:map(mode, lhs, plug) abort
@@ -21,4 +22,5 @@ endfunction
2122
call s:map('n', '<F1>', 'omnisharp_testrunner_togglebanner')
2223
call s:map('n', '<F5>', 'omnisharp_testrunner_run')
2324
call s:map('n', '<F6>', 'omnisharp_testrunner_debug')
25+
call s:map('n', '<F9>', 'omnisharp_testrunner_set_breakpoints')
2426
call s:map('n', '<CR>', 'omnisharp_testrunner_navigate')

0 commit comments

Comments
 (0)