diff runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 18130:1e5672da6a69

Updte runtime files Commit: https://github.com/vim/vim/commit/589edb340454e7f1b19358f129287a636d53d0e1 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 20 14:38:13 2019 +0200 Updte runtime files
author Bram Moolenaar <Bram@vim.org>
date Fri, 20 Sep 2019 14:45:05 +0200
parents 58bebe21f0ef
children 40344f717010
line wrap: on
line diff
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -156,9 +156,9 @@ endfunc
 func s:StartDebug_term(dict)
   " Open a terminal window without a job, to run the debugged program in.
   let s:ptybuf = term_start('NONE', {
-        \ 'term_name': 'debugged program',
-        \ 'vertical': s:vertical,
-        \ })
+	\ 'term_name': 'debugged program',
+	\ 'vertical': s:vertical,
+	\ })
   if s:ptybuf == 0
     echoerr 'Failed to open the program terminal window'
     return
@@ -177,10 +177,10 @@ func s:StartDebug_term(dict)
 
   " Create a hidden terminal window to communicate with gdb
   let s:commbuf = term_start('NONE', {
-        \ 'term_name': 'gdb communication',
-        \ 'out_cb': function('s:CommOutput'),
-        \ 'hidden': 1,
-        \ })
+	\ 'term_name': 'gdb communication',
+	\ 'out_cb': function('s:CommOutput'),
+	\ 'hidden': 1,
+	\ })
   if s:commbuf == 0
     echoerr 'Failed to open the communication terminal window'
     exe 'bwipe! ' . s:ptybuf
@@ -196,8 +196,8 @@ func s:StartDebug_term(dict)
   let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args
   call ch_log('executing "' . join(cmd) . '"')
   let s:gdbbuf = term_start(cmd, {
-        \ 'term_finish': 'close',
-        \ })
+	\ 'term_finish': 'close',
+	\ })
   if s:gdbbuf == 0
     echoerr 'Failed to open the gdb terminal window'
     call s:CloseBuffers()
@@ -229,17 +229,17 @@ func s:StartDebug_term(dict)
       let line1 = term_getline(s:gdbbuf, lnum)
       let line2 = term_getline(s:gdbbuf, lnum + 1)
       if line1 =~ 'new-ui mi '
-        " response can be in the same line or the next line
-        let response = line1 . line2
-        if response =~ 'Undefined command'
-          echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
+	" response can be in the same line or the next line
+	let response = line1 . line2
+	if response =~ 'Undefined command'
+	  echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
 	  call s:CloseBuffers()
-          return
-        endif
-        if response =~ 'New UI allocated'
-          " Success!
-          break
-        endif
+	  return
+	endif
+	if response =~ 'New UI allocated'
+	  " Success!
+	  break
+	endif
       elseif line1 =~ 'Reading symbols from' && line2 !~ 'new-ui mi '
 	" Reading symbols might take a while, try more times
 	let try_count -= 1
@@ -300,9 +300,9 @@ func s:StartDebug_prompt(dict)
   call ch_log('executing "' . join(cmd) . '"')
 
   let s:gdbjob = job_start(cmd, {
-        \ 'exit_cb': function('s:EndPromptDebug'),
-        \ 'out_cb': function('s:GdbOutCallback'),
-        \ })
+	\ 'exit_cb': function('s:EndPromptDebug'),
+	\ 'out_cb': function('s:GdbOutCallback'),
+	\ })
   if job_status(s:gdbjob) != "run"
     echoerr 'Failed to start gdb'
     exe 'bwipe! ' . s:promptbuf
@@ -327,8 +327,8 @@ func s:StartDebug_prompt(dict)
     " Unix: Run the debugged program in a terminal window.  Open it below the
     " gdb window.
     belowright let s:ptybuf = term_start('NONE', {
-          \ 'term_name': 'debugged program',
-          \ })
+	  \ 'term_name': 'debugged program',
+	  \ })
     if s:ptybuf == 0
       echoerr 'Failed to open the program terminal window'
       call job_stop(s:gdbjob)
@@ -508,9 +508,14 @@ func s:DecodeMessage(quotedText)
     if a:quotedText[i] == '\'
       let i += 1
       if a:quotedText[i] == 'n'
-        " drop \n
-        let i += 1
-        continue
+	" drop \n
+	let i += 1
+	continue
+      elseif a:quotedText[i] == 't'
+	" append \t
+	let i += 1
+	let result .= "\t"
+	continue
       endif
     endif
     let result .= a:quotedText[i]
@@ -594,28 +599,38 @@ func s:CommOutput(chan, msg)
     endif
     if msg != ''
       if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)'
-        call s:HandleCursor(msg)
+	call s:HandleCursor(msg)
       elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,'
-        call s:HandleNewBreakpoint(msg)
+	call s:HandleNewBreakpoint(msg)
       elseif msg =~ '^=breakpoint-deleted,'
-        call s:HandleBreakpointDelete(msg)
+	call s:HandleBreakpointDelete(msg)
       elseif msg =~ '^=thread-group-started'
-        call s:HandleProgramRun(msg)
+	call s:HandleProgramRun(msg)
       elseif msg =~ '^\^done,value='
-        call s:HandleEvaluate(msg)
+	call s:HandleEvaluate(msg)
       elseif msg =~ '^\^error,msg='
-        call s:HandleError(msg)
+	call s:HandleError(msg)
       endif
     endif
   endfor
 endfunc
 
+func s:GotoProgram()
+  if has('win32')
+    if executable('powershell')
+      call system(printf('powershell -Command "add-type -AssemblyName microsoft.VisualBasic;[Microsoft.VisualBasic.Interaction]::AppActivate(%d);"', s:pid))
+    endif
+  else
+    win_gotoid(s:ptywin)
+  endif
+endfunc
+
 " Install commands in the current window to control the debugger.
 func s:InstallCommands()
   let save_cpo = &cpo
   set cpo&vim
 
-  command Break call s:SetBreakpoint()
+  command -nargs=? Break call s:SetBreakpoint(<q-args>)
   command Clear call s:ClearBreakpoint()
   command Step call s:SendCommand('-exec-step')
   command Over call s:SendCommand('-exec-next')
@@ -633,7 +648,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 Program call s:GotoProgram()
   command Source call s:GotoSourcewinOrCreateIt()
   command Winbar call s:InstallWinbar()
 
@@ -695,12 +710,12 @@ func s:DeleteCommands()
     let curwinid = win_getid(winnr())
     for winid in s:winbar_winids
       if win_gotoid(winid)
-        aunmenu WinBar.Step
-        aunmenu WinBar.Next
-        aunmenu WinBar.Finish
-        aunmenu WinBar.Cont
-        aunmenu WinBar.Stop
-        aunmenu WinBar.Eval
+	aunmenu WinBar.Step
+	aunmenu WinBar.Next
+	aunmenu WinBar.Finish
+	aunmenu WinBar.Cont
+	aunmenu WinBar.Stop
+	aunmenu WinBar.Eval
       endif
     endfor
     call win_gotoid(curwinid)
@@ -733,7 +748,7 @@ func s:DeleteCommands()
 endfunc
 
 " :Break - Set a breakpoint at the cursor position.
-func s:SetBreakpoint()
+func s:SetBreakpoint(at)
   " Setting a breakpoint may not work while the program is running.
   " Interrupt to make it work.
   let do_continue = 0
@@ -746,9 +761,11 @@ func s:SetBreakpoint()
     endif
     sleep 10m
   endif
+
   " Use the fname:lnum format, older gdb can't handle --source.
-  call s:SendCommand('-break-insert '
-        \ . fnameescape(expand('%:p')) . ':' . line('.'))
+  let at = empty(a:at) ?
+        \ fnameescape(expand('%:p')) . ':' . line('.') : a:at
+  call s:SendCommand('-break-insert ' . at)
   if do_continue
     call s:SendCommand('-exec-continue')
   endif
@@ -763,14 +780,14 @@ func s:ClearBreakpoint()
     let idx = 0
     for id in s:breakpoint_locations[bploc]
       if has_key(s:breakpoints, id)
-        " Assume this always works, the reply is simply "^done".
-        call s:SendCommand('-break-delete ' . id)
-        for subid in keys(s:breakpoints[id])
-          exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
-        endfor
-        unlet s:breakpoints[id]
-        unlet s:breakpoint_locations[bploc][idx]
-        break
+	" Assume this always works, the reply is simply "^done".
+	call s:SendCommand('-break-delete ' . id)
+	for subid in keys(s:breakpoints[id])
+	  exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
+	endfor
+	unlet s:breakpoints[id]
+	unlet s:breakpoint_locations[bploc][idx]
+	break
       else
 	let idx += 1
       endif
@@ -899,14 +916,14 @@ func s:HandleCursor(msg)
     if lnum =~ '^[0-9]*$'
     call s:GotoSourcewinOrCreateIt()
       if expand('%:p') != fnamemodify(fname, ':p')
-        if &modified
-          " TODO: find existing window
-          exe 'split ' . fnameescape(fname)
-          let s:sourcewin = win_getid(winnr())
-          call s:InstallWinbar()
-        else
-          exe 'edit ' . fnameescape(fname)
-        endif
+	if &modified
+	  " TODO: find existing window
+	  exe 'split ' . fnameescape(fname)
+	  let s:sourcewin = win_getid(winnr())
+	  call s:InstallWinbar()
+	else
+	  exe 'edit ' . fnameescape(fname)
+	endif
       endif
       exe lnum
       exe 'sign unplace ' . s:pc_id
@@ -1001,8 +1018,8 @@ func s:HandleBreakpointDelete(msg)
   if has_key(s:breakpoints, id)
     for [subid, entry] in items(s:breakpoints[id])
       if has_key(entry, 'placed')
-        exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
-        unlet entry['placed']
+	exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
+	unlet entry['placed']
       endif
     endfor
     unlet s:breakpoints[id]
@@ -1026,7 +1043,7 @@ func s:BufRead()
   for [id, entries] in items(s:breakpoints)
     for [subid, entry] in items(entries)
       if entry['fname'] == fname
-        call s:PlaceSign(id, subid, entry)
+	call s:PlaceSign(id, subid, entry)
       endif
     endfor
   endfor
@@ -1038,7 +1055,7 @@ func s:BufUnloaded()
   for [id, entries] in items(s:breakpoints)
     for [subid, entry] in items(entries)
       if entry['fname'] == fname
-        let entry['placed'] = 0
+	let entry['placed'] = 0
       endif
     endfor
   endfor