To: vim_dev@googlegroups.com Subject: Patch 8.0.1668 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1668 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. Files: runtime/pack/dist/opt/termdebug/plugin/termdebug.vim, runtime/doc/terminal.txt *** ../vim-8.0.1667/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim 2018-03-29 18:29:47.297127408 +0200 --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim 2018-04-06 22:17:33.335916792 +0200 *************** *** 246,251 **** --- 246,252 ---- command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) command Program call win_gotoid(s:ptywin) + command Source call s:GotoStartwinOrCreateIt() command Winbar call s:InstallWinbar() " TODO: can the K mapping be restored? *************** *** 269,281 **** " Install the window toolbar in the current window. func s:InstallWinbar() ! nnoremenu WinBar.Step :Step ! nnoremenu WinBar.Next :Over ! nnoremenu WinBar.Finish :Finish ! nnoremenu WinBar.Cont :Continue ! nnoremenu WinBar.Stop :Stop ! nnoremenu WinBar.Eval :Evaluate ! call add(s:winbar_winids, win_getid(winnr())) endfunc " Delete installed debugger commands in the current window. --- 270,284 ---- " Install the window toolbar in the current window. func s:InstallWinbar() ! if has('menu') && &mouse != '' ! nnoremenu WinBar.Step :Step ! nnoremenu WinBar.Next :Over ! nnoremenu WinBar.Finish :Finish ! nnoremenu WinBar.Cont :Continue ! nnoremenu WinBar.Stop :Stop ! nnoremenu WinBar.Eval :Evaluate ! call add(s:winbar_winids, win_getid(winnr())) ! endif endfunc " Delete installed debugger commands in the current window. *************** *** 450,455 **** --- 453,466 ---- echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') endfunc + func s:GotoStartwinOrCreateIt() + if !win_gotoid(s:startwin) + new + let s:startwin = win_getid(winnr()) + call s:InstallWinbar() + endif + endfunc + " Handle stopping and running message from gdb. " Will update the sign that shows the current position. func s:HandleCursor(msg) *************** *** 461,491 **** let s:stopped = 0 endif ! if win_gotoid(s:startwin) ! let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '') ! if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname) ! let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '') ! if lnum =~ '^[0-9]*$' ! if expand('%:p') != fnamemodify(fname, ':p') ! if &modified ! " TODO: find existing window ! exe 'split ' . fnameescape(fname) ! let s:startwin = win_getid(winnr()) ! else ! exe 'edit ' . fnameescape(fname) ! endif endif - exe lnum - exe 'sign unplace ' . s:pc_id - exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname - setlocal signcolumn=yes endif ! else exe 'sign unplace ' . s:pc_id endif ! ! call win_gotoid(wid) endif endfunc " Handle setting a breakpoint --- 472,503 ---- let s:stopped = 0 endif ! call s:GotoStartwinOrCreateIt() ! ! let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '') ! if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname) ! let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '') ! if lnum =~ '^[0-9]*$' ! if expand('%:p') != fnamemodify(fname, ':p') ! if &modified ! " TODO: find existing window ! exe 'split ' . fnameescape(fname) ! let s:startwin = win_getid(winnr()) ! call s:InstallWinbar() ! else ! exe 'edit ' . fnameescape(fname) endif endif ! exe lnum exe 'sign unplace ' . s:pc_id + exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname + setlocal signcolumn=yes endif ! else ! exe 'sign unplace ' . s:pc_id endif + + call win_gotoid(wid) endfunc " Handle setting a breakpoint *** ../vim-8.0.1667/runtime/doc/terminal.txt 2018-04-05 22:59:37.198608805 +0200 --- runtime/doc/terminal.txt 2018-04-06 22:22:04.258510491 +0200 *************** *** 731,736 **** --- 731,741 ---- You can add the window toolbar in other windows you open with: > :Winbar + If gdb stops at a source line and there is no window currently showing the + source code, a new window will be created for the source code. This also + happens if the buffer in the source code window has been modified and can't be + abandoned. + Inspecting variables ~ *termdebug-variables* *************** *** 745,752 **** Other commands ~ *termdebug-commands* ! :Gdb jump to the gdb window ! :Program jump to the window with the running program Communication ~ --- 750,759 ---- Other commands ~ *termdebug-commands* ! :Gdb jump to the gdb window ! :Program jump to the window with the running program ! :Source jump to the window with the source code, create it if there ! isn't one Communication ~ *** ../vim-8.0.1667/src/version.c 2018-04-06 20:22:01.851568646 +0200 --- src/version.c 2018-04-06 22:23:38.306023254 +0200 *************** *** 764,765 **** --- 764,767 ---- { /* Add new patch number below this line */ + /**/ + 1668, /**/ -- Amnesia is one of my favorite words, but I forgot what it means. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///