]> granicus.if.org Git - vim/commitdiff
patch 8.0.1668: terminal debugger: can't re-open source code window v8.0.1668
authorBram Moolenaar <Bram@vim.org>
Fri, 6 Apr 2018 20:26:25 +0000 (22:26 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 6 Apr 2018 20:26:25 +0000 (22:26 +0200)
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.

runtime/doc/terminal.txt
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
src/version.c

index 9a1c1d229c5aac5c175530b224f746f0bf132ba0..2d1af112668ac44c631a8781b88f6d0e536325bf 100644 (file)
@@ -731,6 +731,11 @@ to have the 'mouse' option set to enable mouse clicks.
 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,8 +750,10 @@ You can usually shorten `:Evaluate` to `:Ev`.
 
 Other commands ~
                                                        *termdebug-commands*
- :Gdb         jump to the gdb window
- :Program      jump to the window with the running program
+ :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 ~
index 086a8f1ecf2e5e0a0035c3600c250587c44467de..256f7ef60c14cb8938055a02aa98f672a546b36c 100644 (file)
@@ -246,6 +246,7 @@ func s:InstallCommands()
   command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>)
   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,13 +270,15 @@ let s:winbar_winids = []
 
 " Install the window toolbar in the current window.
 func s:InstallWinbar()
-  nnoremenu WinBar.Step   :Step<CR>
-  nnoremenu WinBar.Next   :Over<CR>
-  nnoremenu WinBar.Finish :Finish<CR>
-  nnoremenu WinBar.Cont   :Continue<CR>
-  nnoremenu WinBar.Stop   :Stop<CR>
-  nnoremenu WinBar.Eval   :Evaluate<CR>
-  call add(s:winbar_winids, win_getid(winnr()))
+  if has('menu') && &mouse != ''
+    nnoremenu WinBar.Step   :Step<CR>
+    nnoremenu WinBar.Next   :Over<CR>
+    nnoremenu WinBar.Finish :Finish<CR>
+    nnoremenu WinBar.Cont   :Continue<CR>
+    nnoremenu WinBar.Stop   :Stop<CR>
+    nnoremenu WinBar.Eval   :Evaluate<CR>
+    call add(s:winbar_winids, win_getid(winnr()))
+  endif
 endfunc
 
 " Delete installed debugger commands in the current window.
@@ -450,6 +453,14 @@ func s:HandleError(msg)
   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,31 +472,32 @@ func s:HandleCursor(msg)
     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
+  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
-       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 lnum
       exe 'sign unplace ' . s:pc_id
+      exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname
+      setlocal signcolumn=yes
     endif
-
-    call win_gotoid(wid)
+  else
+    exe 'sign unplace ' . s:pc_id
   endif
+
+  call win_gotoid(wid)
 endfunc
 
 " Handle setting a breakpoint
index c625b05c163f8efa0f93159202676fed0b91e524..33bae20366fec25c2b0f3b0ba0dd1e0fec4099d3 100644 (file)
@@ -762,6 +762,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1668,
 /**/
     1667,
 /**/