Mercurial > vim
comparison runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 13592:a64485061f75 v8.0.1668
patch 8.0.1668: terminal debugger: can't re-open source code window
commit https://github.com/vim/vim/commit/c4b533e1e93151658cb170c6796d327a8c0f8612
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 6 22:26:25 2018 +0200
patch 8.0.1668: terminal debugger: can't re-open source code window
Problem: Terminal debugger: can't re-open source code window.
Solution: Add the :Source command. Also create the window if needed when
gdb stops at a source line.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 06 Apr 2018 22:30:07 +0200 |
parents | a036c2cf4024 |
children | fc660a6ef37d |
comparison
equal
deleted
inserted
replaced
13591:035fc9d3dd9b | 13592:a64485061f75 |
---|---|
244 command Stop call s:SendCommand('-exec-interrupt') | 244 command Stop call s:SendCommand('-exec-interrupt') |
245 command Continue call s:SendCommand('-exec-continue') | 245 command Continue call s:SendCommand('-exec-continue') |
246 command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>) | 246 command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>) |
247 command Gdb call win_gotoid(s:gdbwin) | 247 command Gdb call win_gotoid(s:gdbwin) |
248 command Program call win_gotoid(s:ptywin) | 248 command Program call win_gotoid(s:ptywin) |
249 command Source call s:GotoStartwinOrCreateIt() | |
249 command Winbar call s:InstallWinbar() | 250 command Winbar call s:InstallWinbar() |
250 | 251 |
251 " TODO: can the K mapping be restored? | 252 " TODO: can the K mapping be restored? |
252 nnoremap K :Evaluate<CR> | 253 nnoremap K :Evaluate<CR> |
253 | 254 |
267 | 268 |
268 let s:winbar_winids = [] | 269 let s:winbar_winids = [] |
269 | 270 |
270 " Install the window toolbar in the current window. | 271 " Install the window toolbar in the current window. |
271 func s:InstallWinbar() | 272 func s:InstallWinbar() |
272 nnoremenu WinBar.Step :Step<CR> | 273 if has('menu') && &mouse != '' |
273 nnoremenu WinBar.Next :Over<CR> | 274 nnoremenu WinBar.Step :Step<CR> |
274 nnoremenu WinBar.Finish :Finish<CR> | 275 nnoremenu WinBar.Next :Over<CR> |
275 nnoremenu WinBar.Cont :Continue<CR> | 276 nnoremenu WinBar.Finish :Finish<CR> |
276 nnoremenu WinBar.Stop :Stop<CR> | 277 nnoremenu WinBar.Cont :Continue<CR> |
277 nnoremenu WinBar.Eval :Evaluate<CR> | 278 nnoremenu WinBar.Stop :Stop<CR> |
278 call add(s:winbar_winids, win_getid(winnr())) | 279 nnoremenu WinBar.Eval :Evaluate<CR> |
280 call add(s:winbar_winids, win_getid(winnr())) | |
281 endif | |
279 endfunc | 282 endfunc |
280 | 283 |
281 " Delete installed debugger commands in the current window. | 284 " Delete installed debugger commands in the current window. |
282 func s:DeleteCommands() | 285 func s:DeleteCommands() |
283 delcommand Break | 286 delcommand Break |
448 return | 451 return |
449 endif | 452 endif |
450 echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') | 453 echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') |
451 endfunc | 454 endfunc |
452 | 455 |
456 func s:GotoStartwinOrCreateIt() | |
457 if !win_gotoid(s:startwin) | |
458 new | |
459 let s:startwin = win_getid(winnr()) | |
460 call s:InstallWinbar() | |
461 endif | |
462 endfunc | |
463 | |
453 " Handle stopping and running message from gdb. | 464 " Handle stopping and running message from gdb. |
454 " Will update the sign that shows the current position. | 465 " Will update the sign that shows the current position. |
455 func s:HandleCursor(msg) | 466 func s:HandleCursor(msg) |
456 let wid = win_getid(winnr()) | 467 let wid = win_getid(winnr()) |
457 | 468 |
459 let s:stopped = 1 | 470 let s:stopped = 1 |
460 elseif a:msg =~ '^\*running' | 471 elseif a:msg =~ '^\*running' |
461 let s:stopped = 0 | 472 let s:stopped = 0 |
462 endif | 473 endif |
463 | 474 |
464 if win_gotoid(s:startwin) | 475 call s:GotoStartwinOrCreateIt() |
465 let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '') | 476 |
466 if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname) | 477 let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '') |
467 let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '') | 478 if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname) |
468 if lnum =~ '^[0-9]*$' | 479 let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '') |
469 if expand('%:p') != fnamemodify(fname, ':p') | 480 if lnum =~ '^[0-9]*$' |
470 if &modified | 481 if expand('%:p') != fnamemodify(fname, ':p') |
471 " TODO: find existing window | 482 if &modified |
472 exe 'split ' . fnameescape(fname) | 483 " TODO: find existing window |
473 let s:startwin = win_getid(winnr()) | 484 exe 'split ' . fnameescape(fname) |
474 else | 485 let s:startwin = win_getid(winnr()) |
475 exe 'edit ' . fnameescape(fname) | 486 call s:InstallWinbar() |
476 endif | 487 else |
488 exe 'edit ' . fnameescape(fname) | |
477 endif | 489 endif |
478 exe lnum | |
479 exe 'sign unplace ' . s:pc_id | |
480 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname | |
481 setlocal signcolumn=yes | |
482 endif | 490 endif |
483 else | 491 exe lnum |
484 exe 'sign unplace ' . s:pc_id | 492 exe 'sign unplace ' . s:pc_id |
485 endif | 493 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname |
486 | 494 setlocal signcolumn=yes |
487 call win_gotoid(wid) | 495 endif |
488 endif | 496 else |
497 exe 'sign unplace ' . s:pc_id | |
498 endif | |
499 | |
500 call win_gotoid(wid) | |
489 endfunc | 501 endfunc |
490 | 502 |
491 " Handle setting a breakpoint | 503 " Handle setting a breakpoint |
492 " Will update the sign that shows the breakpoint | 504 " Will update the sign that shows the breakpoint |
493 func s:HandleNewBreakpoint(msg) | 505 func s:HandleNewBreakpoint(msg) |