mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:83d0028: runtime(termdebug): Use string interpolation instead of string concat
closes: vim/vim#14972
83d0028026
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
parent
167d0e5a6c
commit
c909efb96f
168
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
vendored
168
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
vendored
@ -45,7 +45,7 @@
|
|||||||
" - balloon -> vim.lsp.util.open_floating_preview
|
" - balloon -> vim.lsp.util.open_floating_preview
|
||||||
|
|
||||||
func s:Echoerr(msg)
|
func s:Echoerr(msg)
|
||||||
echohl ErrorMsg | echom '[termdebug] ' .. a:msg | echohl None
|
echohl ErrorMsg | echom $'[termdebug] {a:msg}' | echohl None
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" In case this gets sourced twice.
|
" In case this gets sourced twice.
|
||||||
@ -91,9 +91,9 @@ endfunction
|
|||||||
func s:Highlight(init, old, new)
|
func s:Highlight(init, old, new)
|
||||||
let default = a:init ? 'default ' : ''
|
let default = a:init ? 'default ' : ''
|
||||||
if a:new ==# 'light' && a:old !=# 'light'
|
if a:new ==# 'light' && a:old !=# 'light'
|
||||||
exe "hi " . default . "debugPC term=reverse ctermbg=lightblue guibg=lightblue"
|
exe $"hi {default}debugPC term=reverse ctermbg=lightblue guibg=lightblue"
|
||||||
elseif a:new ==# 'dark' && a:old !=# 'dark'
|
elseif a:new ==# 'dark' && a:old !=# 'dark'
|
||||||
exe "hi " . default . "debugPC term=reverse ctermbg=darkblue guibg=darkblue"
|
exe $"hi {default}debugPC term=reverse ctermbg=darkblue guibg=darkblue"
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ func s:StartDebug_internal(dict)
|
|||||||
endif
|
endif
|
||||||
let gdbcmd = s:GetCommand()
|
let gdbcmd = s:GetCommand()
|
||||||
if !executable(gdbcmd[0])
|
if !executable(gdbcmd[0])
|
||||||
call s:Echoerr('Cannot execute debugger program "' .. gdbcmd[0] .. '"')
|
call s:Echoerr($'Cannot execute debugger program "{gdbcmd[0]}"')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -227,12 +227,12 @@ endfunc
|
|||||||
|
|
||||||
" Use when debugger didn't start or ended.
|
" Use when debugger didn't start or ended.
|
||||||
func s:CloseBuffers()
|
func s:CloseBuffers()
|
||||||
exe 'bwipe! ' . s:ptybufnr
|
exe $'bwipe! {s:ptybufnr}'
|
||||||
if s:asmbufnr > 0 && bufexists(s:asmbufnr)
|
if s:asmbufnr > 0 && bufexists(s:asmbufnr)
|
||||||
exe 'bwipe! ' . s:asmbufnr
|
exe $'bwipe! {s:asmbufnr}'
|
||||||
endif
|
endif
|
||||||
if s:varbufnr > 0 && bufexists(s:varbufnr)
|
if s:varbufnr > 0 && bufexists(s:varbufnr)
|
||||||
exe 'bwipe! ' . s:varbufnr
|
exe $'bwipe! {s:varbufnr}'
|
||||||
endif
|
endif
|
||||||
let s:running = v:false
|
let s:running = v:false
|
||||||
unlet! s:gdbwin
|
unlet! s:gdbwin
|
||||||
@ -240,7 +240,8 @@ endfunc
|
|||||||
|
|
||||||
func s:IsGdbStarted()
|
func s:IsGdbStarted()
|
||||||
if !s:gdb_running
|
if !s:gdb_running
|
||||||
call s:Echoerr(string(s:GetCommand()[0]) . ' exited unexpectedly')
|
let cmd_name = string(s:GetCommand()[0])
|
||||||
|
call s:Echoerr($'{cmd_name} exited unexpectedly')
|
||||||
call s:CloseBuffers()
|
call s:CloseBuffers()
|
||||||
return v:false
|
return v:false
|
||||||
endif
|
endif
|
||||||
@ -265,7 +266,7 @@ func s:StartDebug_term(dict)
|
|||||||
if s:vertical
|
if s:vertical
|
||||||
" Assuming the source code window will get a signcolumn, use two more
|
" Assuming the source code window will get a signcolumn, use two more
|
||||||
" columns for that, thus one less for the terminal window.
|
" columns for that, thus one less for the terminal window.
|
||||||
exe (&columns / 2 - 1) . "wincmd |"
|
exe $":{(&columns / 2 - 1)}wincmd |"
|
||||||
if s:allleft
|
if s:allleft
|
||||||
" use the whole left column
|
" use the whole left column
|
||||||
wincmd H
|
wincmd H
|
||||||
@ -284,7 +285,7 @@ func s:StartDebug_term(dict)
|
|||||||
return
|
return
|
||||||
elseif s:comm_job_id == -1
|
elseif s:comm_job_id == -1
|
||||||
call s:Echoerr('Failed to open the communication terminal window')
|
call s:Echoerr('Failed to open the communication terminal window')
|
||||||
exe 'bwipe! ' . s:ptybufnr
|
exe $'bwipe! {s:ptybufnr}'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let comm_job_info = nvim_get_chan_info(s:comm_job_id)
|
let comm_job_info = nvim_get_chan_info(s:comm_job_id)
|
||||||
@ -321,7 +322,7 @@ func s:StartDebug_term(dict)
|
|||||||
let gdb_cmd += gdb_args
|
let gdb_cmd += gdb_args
|
||||||
|
|
||||||
execute 'new'
|
execute 'new'
|
||||||
" call ch_log('executing "' . join(gdb_cmd) . '"')
|
" call ch_log($'executing "{join(gdb_cmd)}"')
|
||||||
let s:gdb_job_id = termopen(gdb_cmd, {'on_exit': function('s:EndTermDebug')})
|
let s:gdb_job_id = termopen(gdb_cmd, {'on_exit': function('s:EndTermDebug')})
|
||||||
if s:gdb_job_id == 0
|
if s:gdb_job_id == 0
|
||||||
call s:Echoerr('Invalid argument (or job table is full) while opening gdb terminal window')
|
call s:Echoerr('Invalid argument (or job table is full) while opening gdb terminal window')
|
||||||
@ -361,12 +362,12 @@ func s:StartDebug_term(dict)
|
|||||||
|
|
||||||
" Set arguments to be run.
|
" Set arguments to be run.
|
||||||
if len(proc_args)
|
if len(proc_args)
|
||||||
call chansend(s:gdb_job_id, 'server set args ' . join(proc_args) . "\r")
|
call chansend(s:gdb_job_id, $"server set args {join(proc_args)}\r")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Connect gdb to the communication pty, using the GDB/MI interface.
|
" Connect gdb to the communication pty, using the GDB/MI interface.
|
||||||
" Prefix "server" to avoid adding this to the history.
|
" Prefix "server" to avoid adding this to the history.
|
||||||
call chansend(s:gdb_job_id, 'server new-ui mi ' . commpty . "\r")
|
call chansend(s:gdb_job_id, $"server new-ui mi {commpty}\r")
|
||||||
|
|
||||||
" Wait for the response to show up, users may not notice the error and wonder
|
" Wait for the response to show up, users may not notice the error and wonder
|
||||||
" why the debugger doesn't work.
|
" why the debugger doesn't work.
|
||||||
@ -445,7 +446,7 @@ func s:StartDebug_prompt(dict)
|
|||||||
if s:vertical
|
if s:vertical
|
||||||
" Assuming the source code window will get a signcolumn, use two more
|
" Assuming the source code window will get a signcolumn, use two more
|
||||||
" columns for that, thus one less for the terminal window.
|
" columns for that, thus one less for the terminal window.
|
||||||
exe (&columns / 2 - 1) . "wincmd |"
|
exe $":{(&columns / 2 - 1)}wincmd |"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let gdb_args = get(a:dict, 'gdb_args', [])
|
let gdb_args = get(a:dict, 'gdb_args', [])
|
||||||
@ -466,14 +467,14 @@ func s:StartDebug_prompt(dict)
|
|||||||
" Adding arguments requested by the user
|
" Adding arguments requested by the user
|
||||||
let gdb_cmd += gdb_args
|
let gdb_cmd += gdb_args
|
||||||
|
|
||||||
" call ch_log('executing "' . join(gdb_cmd) . '"')
|
" call ch_log($'executing "{join(gdb_cmd)}"')
|
||||||
let s:gdbjob = jobstart(gdb_cmd, {
|
let s:gdbjob = jobstart(gdb_cmd, {
|
||||||
\ 'on_exit': function('s:EndPromptDebug'),
|
\ 'on_exit': function('s:EndPromptDebug'),
|
||||||
\ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:GdbOutCallback')}),
|
\ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:GdbOutCallback')}),
|
||||||
\ })
|
\ })
|
||||||
if s:gdbjob == 0
|
if s:gdbjob == 0
|
||||||
call s:Echoerr('Invalid argument (or job table is full) while starting gdb job')
|
call s:Echoerr('Invalid argument (or job table is full) while starting gdb job')
|
||||||
exe 'bwipe! ' . s:ptybufnr
|
exe $'bwipe! {s:ptybufnr}'
|
||||||
return
|
return
|
||||||
elseif s:gdbjob == -1
|
elseif s:gdbjob == -1
|
||||||
call s:Echoerr('Failed to start the gdb job')
|
call s:Echoerr('Failed to start the gdb job')
|
||||||
@ -502,23 +503,23 @@ func s:StartDebug_prompt(dict)
|
|||||||
let s:ptybufnr = pty_job_info['buffer']
|
let s:ptybufnr = pty_job_info['buffer']
|
||||||
let pty = pty_job_info['pty']
|
let pty = pty_job_info['pty']
|
||||||
let s:ptywin = win_getid()
|
let s:ptywin = win_getid()
|
||||||
call s:SendCommand('tty ' . pty)
|
call s:SendCommand($'tty {pty}')
|
||||||
|
|
||||||
" Since GDB runs in a prompt window, the environment has not been set to
|
" Since GDB runs in a prompt window, the environment has not been set to
|
||||||
" match a terminal window, need to do that now.
|
" match a terminal window, need to do that now.
|
||||||
call s:SendCommand('set env TERM = xterm-color')
|
call s:SendCommand('set env TERM = xterm-color')
|
||||||
call s:SendCommand('set env ROWS = ' . winheight(s:ptywin))
|
call s:SendCommand($'set env ROWS = {winheight(s:ptywin)}')
|
||||||
call s:SendCommand('set env LINES = ' . winheight(s:ptywin))
|
call s:SendCommand($'set env LINES = {winheight(s:ptywin)}')
|
||||||
call s:SendCommand('set env COLUMNS = ' . winwidth(s:ptywin))
|
call s:SendCommand($'set env COLUMNS = {winwidth(s:ptywin)}')
|
||||||
call s:SendCommand('set env COLORS = ' . &t_Co)
|
call s:SendCommand($'set env COLORS = {&t_Co}')
|
||||||
call s:SendCommand('set env VIM_TERMINAL = ' . v:version)
|
call s:SendCommand($'set env VIM_TERMINAL = {v:version}')
|
||||||
endif
|
endif
|
||||||
call s:SendCommand('set print pretty on')
|
call s:SendCommand('set print pretty on')
|
||||||
call s:SendCommand('set breakpoint pending on')
|
call s:SendCommand('set breakpoint pending on')
|
||||||
|
|
||||||
" Set arguments to be run
|
" Set arguments to be run
|
||||||
if len(proc_args)
|
if len(proc_args)
|
||||||
call s:SendCommand('set args ' . join(proc_args))
|
call s:SendCommand($'set args {join(proc_args)}')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:StartDebugCommon(a:dict)
|
call s:StartDebugCommon(a:dict)
|
||||||
@ -564,18 +565,18 @@ endfunc
|
|||||||
|
|
||||||
" Send a command to gdb. "cmd" is the string without line terminator.
|
" Send a command to gdb. "cmd" is the string without line terminator.
|
||||||
func s:SendCommand(cmd)
|
func s:SendCommand(cmd)
|
||||||
"call ch_log('sending to gdb: ' . a:cmd)
|
" call ch_log($'sending to gdb: {a:cmd}')
|
||||||
if s:way == 'prompt'
|
if s:way == 'prompt'
|
||||||
call chansend(s:gdbjob, a:cmd . "\n")
|
call chansend(s:gdbjob, $"{a:cmd}\n")
|
||||||
else
|
else
|
||||||
call chansend(s:comm_job_id, a:cmd . "\r")
|
call chansend(s:comm_job_id, $"{a:cmd}\r")
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" This is global so that a user can create their mappings with this.
|
" This is global so that a user can create their mappings with this.
|
||||||
func TermDebugSendCommand(cmd)
|
func TermDebugSendCommand(cmd)
|
||||||
if s:way == 'prompt'
|
if s:way == 'prompt'
|
||||||
call chansend(s:gdbjob, a:cmd . "\n")
|
call chansend(s:gdbjob, $"{a:cmd}\n")
|
||||||
else
|
else
|
||||||
let do_continue = 0
|
let do_continue = 0
|
||||||
if !s:stopped
|
if !s:stopped
|
||||||
@ -590,7 +591,7 @@ func TermDebugSendCommand(cmd)
|
|||||||
sleep 10m
|
sleep 10m
|
||||||
endif
|
endif
|
||||||
" TODO: should we prepend CTRL-U to clear the command?
|
" TODO: should we prepend CTRL-U to clear the command?
|
||||||
call chansend(s:gdb_job_id, a:cmd . "\r")
|
call chansend(s:gdb_job_id, $"{a:cmd}\r")
|
||||||
if do_continue
|
if do_continue
|
||||||
Continue
|
Continue
|
||||||
endif
|
endif
|
||||||
@ -607,7 +608,7 @@ func s:SendResumingCommand(cmd)
|
|||||||
" call ch_log('assume that program is running after this command')
|
" call ch_log('assume that program is running after this command')
|
||||||
call s:SendCommand(a:cmd)
|
call s:SendCommand(a:cmd)
|
||||||
" else
|
" else
|
||||||
" call ch_log('dropping command, program is running: ' . a:cmd)
|
" call ch_log($'dropping command, program is running: {a:cmd}')
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -652,7 +653,7 @@ endfunc
|
|||||||
|
|
||||||
" Function called when gdb outputs text.
|
" Function called when gdb outputs text.
|
||||||
func s:GdbOutCallback(job_id, msgs, event)
|
func s:GdbOutCallback(job_id, msgs, event)
|
||||||
"call ch_log('received from gdb: ' . a:text)
|
" call ch_log($'received from gdb: {a:text}')
|
||||||
|
|
||||||
let comm_msgs = []
|
let comm_msgs = []
|
||||||
let lines = []
|
let lines = []
|
||||||
@ -711,7 +712,7 @@ endfunc
|
|||||||
" - change \\ to \
|
" - change \\ to \
|
||||||
func s:DecodeMessage(quotedText, literal)
|
func s:DecodeMessage(quotedText, literal)
|
||||||
if a:quotedText[0] != '"'
|
if a:quotedText[0] != '"'
|
||||||
call s:Echoerr('DecodeMessage(): missing quote in ' . a:quotedText)
|
call s:Echoerr($'DecodeMessage(): missing quote in {a:quotedText}')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let msg = a:quotedText
|
let msg = a:quotedText
|
||||||
@ -778,13 +779,13 @@ func s:EndDebugCommon()
|
|||||||
let curwinid = win_getid()
|
let curwinid = win_getid()
|
||||||
|
|
||||||
if exists('s:ptybufnr') && s:ptybufnr
|
if exists('s:ptybufnr') && s:ptybufnr
|
||||||
exe 'bwipe! ' . s:ptybufnr
|
exe $'bwipe! {s:ptybufnr}'
|
||||||
endif
|
endif
|
||||||
if s:asmbufnr > 0 && bufexists(s:asmbufnr)
|
if s:asmbufnr > 0 && bufexists(s:asmbufnr)
|
||||||
exe 'bwipe! ' . s:asmbufnr
|
exe $'bwipe! {s:asmbufnr}'
|
||||||
endif
|
endif
|
||||||
if s:varbufnr > 0 && bufexists(s:varbufnr)
|
if s:varbufnr > 0 && bufexists(s:varbufnr)
|
||||||
exe 'bwipe! ' . s:varbufnr
|
exe $'bwipe! {s:varbufnr}'
|
||||||
endif
|
endif
|
||||||
let s:running = v:false
|
let s:running = v:false
|
||||||
|
|
||||||
@ -793,7 +794,7 @@ func s:EndDebugCommon()
|
|||||||
let was_buf = bufnr()
|
let was_buf = bufnr()
|
||||||
for bufnr in s:signcolumn_buflist
|
for bufnr in s:signcolumn_buflist
|
||||||
if bufexists(bufnr)
|
if bufexists(bufnr)
|
||||||
exe bufnr .. "buf"
|
exe $":{bufnr}buf"
|
||||||
if exists('b:save_signcolumn')
|
if exists('b:save_signcolumn')
|
||||||
let &signcolumn = b:save_signcolumn
|
let &signcolumn = b:save_signcolumn
|
||||||
unlet b:save_signcolumn
|
unlet b:save_signcolumn
|
||||||
@ -801,7 +802,7 @@ func s:EndDebugCommon()
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
if bufexists(was_buf)
|
if bufexists(was_buf)
|
||||||
exe was_buf .. "buf"
|
exe $":{was_buf}buf"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:DeleteCommands()
|
call s:DeleteCommands()
|
||||||
@ -825,7 +826,7 @@ func s:EndPromptDebug(job_id, exit_code, event)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if bufexists(s:promptbuf)
|
if bufexists(s:promptbuf)
|
||||||
exe 'bwipe! ' . s:promptbuf
|
exe $'bwipe! {s:promptbuf}'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:EndDebugCommon()
|
call s:EndDebugCommon()
|
||||||
@ -854,7 +855,7 @@ func s:HandleDisasmMsg(msg)
|
|||||||
set nomodified
|
set nomodified
|
||||||
set filetype=asm
|
set filetype=asm
|
||||||
|
|
||||||
let lnum = search('^' . s:asm_addr)
|
let lnum = search($'^{s:asm_addr}')
|
||||||
if lnum != 0
|
if lnum != 0
|
||||||
call sign_unplace('TermDebug', #{id: s:asm_id})
|
call sign_unplace('TermDebug', #{id: s:asm_id})
|
||||||
call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum})
|
call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum})
|
||||||
@ -916,11 +917,8 @@ func s:HandleVariablesMsg(msg)
|
|||||||
|
|
||||||
silent! %delete _
|
silent! %delete _
|
||||||
let spaceBuffer = 20
|
let spaceBuffer = 20
|
||||||
call setline(1, 'Type' .
|
let spaces = repeat(' ', 16)
|
||||||
\ repeat(' ', 16) .
|
call setline(1, $'Type{spaces}Name{spaces}Value')
|
||||||
\ 'Name' .
|
|
||||||
\ repeat(' ', 16) .
|
|
||||||
\ 'Value')
|
|
||||||
let cnt = 1
|
let cnt = 1
|
||||||
let capture = '{name=".\{-}",\%(arg=".\{-}",\)\{0,1\}type=".\{-}"\%(,value=".\{-}"\)\{0,1\}}'
|
let capture = '{name=".\{-}",\%(arg=".\{-}",\)\{0,1\}type=".\{-}"\%(,value=".\{-}"\)\{0,1\}}'
|
||||||
let varinfo = matchstr(a:msg, capture, 0, cnt)
|
let varinfo = matchstr(a:msg, capture, 0, cnt)
|
||||||
@ -1190,9 +1188,8 @@ func s:Until(at)
|
|||||||
let s:stopped = v:false
|
let s:stopped = v:false
|
||||||
" call ch_log('assume that program is running after this command')
|
" call ch_log('assume that program is running after this command')
|
||||||
" Use the fname:lnum format
|
" Use the fname:lnum format
|
||||||
let at = empty(a:at) ?
|
let at = empty(a:at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : a:at
|
||||||
\ fnameescape(expand('%:p')) . ':' . line('.') : a:at
|
call s:SendCommand($'-exec-until {at}')
|
||||||
call s:SendCommand('-exec-until ' . at)
|
|
||||||
" else
|
" else
|
||||||
" call ch_log('dropping command, program is running: exec-until')
|
" call ch_log('dropping command, program is running: exec-until')
|
||||||
endif
|
endif
|
||||||
@ -1210,12 +1207,11 @@ func s:SetBreakpoint(at, tbreak=v:false)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Use the fname:lnum format, older gdb can't handle --source.
|
" Use the fname:lnum format, older gdb can't handle --source.
|
||||||
let at = empty(a:at) ?
|
let at = empty(a:at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : a:at
|
||||||
\ fnameescape(expand('%:p')) . ':' . line('.') : a:at
|
|
||||||
if a:tbreak
|
if a:tbreak
|
||||||
let cmd = '-break-insert -t ' . at
|
let cmd = $'-break-insert -t {at}'
|
||||||
else
|
else
|
||||||
let cmd = '-break-insert ' . at
|
let cmd = $'-break-insert {at}'
|
||||||
endif
|
endif
|
||||||
call s:SendCommand(cmd)
|
call s:SendCommand(cmd)
|
||||||
if do_continue
|
if do_continue
|
||||||
@ -1234,7 +1230,7 @@ func s:ClearBreakpoint()
|
|||||||
for id in s:breakpoint_locations[bploc]
|
for id in s:breakpoint_locations[bploc]
|
||||||
if has_key(s:breakpoints, id)
|
if has_key(s:breakpoints, id)
|
||||||
" Assume this always works, the reply is simply "^done".
|
" Assume this always works, the reply is simply "^done".
|
||||||
call s:SendCommand('-break-delete ' . id)
|
call s:SendCommand($'-break-delete {id}')
|
||||||
for subid in keys(s:breakpoints[id])
|
for subid in keys(s:breakpoints[id])
|
||||||
call sign_unplace('TermDebug',
|
call sign_unplace('TermDebug',
|
||||||
\ #{id: s:Breakpoint2SignNumber(id, subid)})
|
\ #{id: s:Breakpoint2SignNumber(id, subid)})
|
||||||
@ -1251,18 +1247,18 @@ func s:ClearBreakpoint()
|
|||||||
if empty(s:breakpoint_locations[bploc])
|
if empty(s:breakpoint_locations[bploc])
|
||||||
unlet s:breakpoint_locations[bploc]
|
unlet s:breakpoint_locations[bploc]
|
||||||
endif
|
endif
|
||||||
echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.'
|
echomsg $'Breakpoint {nr} cleared from line {lnum}.'
|
||||||
else
|
else
|
||||||
call s:Echoerr('Internal error trying to remove breakpoint at line ' . lnum . '!')
|
call s:Echoerr($'Internal error trying to remove breakpoint at line {lnum}!')
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
echomsg 'No breakpoint to remove at line ' . lnum . '.'
|
echomsg $'No breakpoint to remove at line {lnum}.'
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func s:Run(args)
|
func s:Run(args)
|
||||||
if a:args != ''
|
if a:args != ''
|
||||||
call s:SendResumingCommand('-exec-arguments ' . a:args)
|
call s:SendResumingCommand($'-exec-arguments {a:args}')
|
||||||
endif
|
endif
|
||||||
call s:SendResumingCommand('-exec-run')
|
call s:SendResumingCommand('-exec-run')
|
||||||
endfunc
|
endfunc
|
||||||
@ -1276,13 +1272,13 @@ func s:Frame(arg)
|
|||||||
" already parsed and allows for more formats
|
" already parsed and allows for more formats
|
||||||
if a:arg =~ '^\d\+$' || a:arg == ''
|
if a:arg =~ '^\d\+$' || a:arg == ''
|
||||||
" specify frame by number
|
" specify frame by number
|
||||||
call s:SendCommand('-interpreter-exec mi "frame ' . a:arg .'"')
|
call s:SendCommand($'-interpreter-exec mi "frame {a:arg}"')
|
||||||
elseif a:arg =~ '^0x[0-9a-fA-F]\+$'
|
elseif a:arg =~ '^0x[0-9a-fA-F]\+$'
|
||||||
" specify frame by stack address
|
" specify frame by stack address
|
||||||
call s:SendCommand('-interpreter-exec mi "frame address ' . a:arg .'"')
|
call s:SendCommand($'-interpreter-exec mi "frame address {a:arg}"')
|
||||||
else
|
else
|
||||||
" specify frame by function name
|
" specify frame by function name
|
||||||
call s:SendCommand('-interpreter-exec mi "frame function ' . a:arg .'"')
|
call s:SendCommand($'-interpreter-exec mi "frame function {a:arg}"')
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -1308,10 +1304,10 @@ func s:SendEval(expr)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" encoding expression to prevent bad errors
|
" encoding expression to prevent bad errors
|
||||||
let expr = a:expr
|
let expr_escaped = a:expr
|
||||||
let expr = substitute(expr, '\\', '\\\\', 'g')
|
\ ->substitute('\\', '\\\\', 'g')
|
||||||
let expr = substitute(expr, '"', '\\"', 'g')
|
\ ->substitute('"', '\\"', 'g')
|
||||||
call s:SendCommand('-data-evaluate-expression "' . expr . '"')
|
call s:SendCommand($'-data-evaluate-expression "{expr_escaped}"')
|
||||||
let s:evalexpr = exprLHS
|
let s:evalexpr = exprLHS
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -1401,9 +1397,9 @@ func s:HandleEvaluate(msg)
|
|||||||
\ ->substitute('
', '\1', '')
|
\ ->substitute('
', '\1', '')
|
||||||
if s:evalFromBalloonExpr
|
if s:evalFromBalloonExpr
|
||||||
if s:evalFromBalloonExprResult == ''
|
if s:evalFromBalloonExprResult == ''
|
||||||
let s:evalFromBalloonExprResult = s:evalexpr . ': ' . value
|
let s:evalFromBalloonExprResult = $'{s:evalexpr}: {value}'
|
||||||
else
|
else
|
||||||
let s:evalFromBalloonExprResult .= ' = ' . value
|
let s:evalFromBalloonExprResult ..= $' = {value}'
|
||||||
endif
|
endif
|
||||||
" NEOVIM:
|
" NEOVIM:
|
||||||
" - Result pretty-printing is not implemented. Vim prettifies the result
|
" - Result pretty-printing is not implemented. Vim prettifies the result
|
||||||
@ -1415,13 +1411,13 @@ func s:HandleEvaluate(msg)
|
|||||||
" first message.
|
" first message.
|
||||||
let s:eval_float_win_id = luaeval('select(2, vim.lsp.util.open_floating_preview(_A))', [s:evalFromBalloonExprResult])
|
let s:eval_float_win_id = luaeval('select(2, vim.lsp.util.open_floating_preview(_A))', [s:evalFromBalloonExprResult])
|
||||||
else
|
else
|
||||||
echomsg '"' . s:evalexpr . '": ' . value
|
echomsg $'"{s:evalexpr}": {value}'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$'
|
if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$'
|
||||||
" Looks like a pointer, also display what it points to.
|
" Looks like a pointer, also display what it points to.
|
||||||
let s:ignoreEvalError = v:true
|
let s:ignoreEvalError = v:true
|
||||||
call s:SendEval('*' . s:evalexpr)
|
call s:SendEval($'*{s:evalexpr}')
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -1472,7 +1468,7 @@ func s:GotoAsmwinOrCreateIt()
|
|||||||
" 60 is approx spaceBuffer * 3
|
" 60 is approx spaceBuffer * 3
|
||||||
if winwidth(0) > (78 + 60)
|
if winwidth(0) > (78 + 60)
|
||||||
let mdf = 'vert'
|
let mdf = 'vert'
|
||||||
exe mdf .. ' ' .. 60 .. 'new'
|
exe $'{mdf} :60new'
|
||||||
else
|
else
|
||||||
exe 'rightbelow new'
|
exe 'rightbelow new'
|
||||||
endif
|
endif
|
||||||
@ -1491,7 +1487,7 @@ func s:GotoAsmwinOrCreateIt()
|
|||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
|
|
||||||
if s:asmbufnr > 0 && bufexists(s:asmbufnr)
|
if s:asmbufnr > 0 && bufexists(s:asmbufnr)
|
||||||
exe 'buffer' . s:asmbufnr
|
exe $'buffer {s:asmbufnr}'
|
||||||
elseif empty(glob('Termdebug-asm-listing'))
|
elseif empty(glob('Termdebug-asm-listing'))
|
||||||
silent file Termdebug-asm-listing
|
silent file Termdebug-asm-listing
|
||||||
let s:asmbufnr = bufnr('Termdebug-asm-listing')
|
let s:asmbufnr = bufnr('Termdebug-asm-listing')
|
||||||
@ -1501,12 +1497,12 @@ func s:GotoAsmwinOrCreateIt()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if mdf != 'vert' && s:GetDisasmWindowHeight() > 0
|
if mdf != 'vert' && s:GetDisasmWindowHeight() > 0
|
||||||
exe 'resize ' .. s:GetDisasmWindowHeight()
|
exe $'resize {s:GetDisasmWindowHeight()}'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if s:asm_addr != ''
|
if s:asm_addr != ''
|
||||||
let lnum = search('^' . s:asm_addr)
|
let lnum = search($'^{s:asm_addr}')
|
||||||
if lnum == 0
|
if lnum == 0
|
||||||
if s:stopped
|
if s:stopped
|
||||||
call s:SendCommand('disassemble $pc')
|
call s:SendCommand('disassemble $pc')
|
||||||
@ -1545,7 +1541,7 @@ func s:GotoVariableswinOrCreateIt()
|
|||||||
" 60 is approx spaceBuffer * 3
|
" 60 is approx spaceBuffer * 3
|
||||||
if winwidth(0) > (78 + 60)
|
if winwidth(0) > (78 + 60)
|
||||||
let mdf = 'vert'
|
let mdf = 'vert'
|
||||||
exe mdf .. ' ' .. 60 .. 'new'
|
exe $'{mdf} :60new'
|
||||||
else
|
else
|
||||||
exe 'rightbelow new'
|
exe 'rightbelow new'
|
||||||
endif
|
endif
|
||||||
@ -1563,7 +1559,7 @@ func s:GotoVariableswinOrCreateIt()
|
|||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
|
|
||||||
if s:varbufnr > 0 && bufexists(s:varbufnr)
|
if s:varbufnr > 0 && bufexists(s:varbufnr)
|
||||||
exe 'buffer' . s:varbufnr
|
exe $'buffer {s:varbufnr}'
|
||||||
elseif empty(glob('Termdebug-variables-listing'))
|
elseif empty(glob('Termdebug-variables-listing'))
|
||||||
silent file Termdebug-variables-listing
|
silent file Termdebug-variables-listing
|
||||||
let s:varbufnr = bufnr('Termdebug-variables-listing')
|
let s:varbufnr = bufnr('Termdebug-variables-listing')
|
||||||
@ -1573,7 +1569,7 @@ func s:GotoVariableswinOrCreateIt()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if mdf != 'vert' && s:GetVariablesWindowHeight() > 0
|
if mdf != 'vert' && s:GetVariablesWindowHeight() > 0
|
||||||
exe 'resize ' .. s:GetVariablesWindowHeight()
|
exe $'resize {s:GetVariablesWindowHeight()}'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1612,7 +1608,7 @@ func s:HandleCursor(msg)
|
|||||||
|
|
||||||
let curwinid = win_getid()
|
let curwinid = win_getid()
|
||||||
if win_gotoid(s:asmwin)
|
if win_gotoid(s:asmwin)
|
||||||
let lnum = search('^' . s:asm_addr)
|
let lnum = search($'^{s:asm_addr}')
|
||||||
if lnum == 0
|
if lnum == 0
|
||||||
call s:SendCommand('disassemble $pc')
|
call s:SendCommand('disassemble $pc')
|
||||||
else
|
else
|
||||||
@ -1634,7 +1630,7 @@ func s:HandleCursor(msg)
|
|||||||
if lnum =~ '^[0-9]*$'
|
if lnum =~ '^[0-9]*$'
|
||||||
call s:GotoSourcewinOrCreateIt()
|
call s:GotoSourcewinOrCreateIt()
|
||||||
if expand('%:p') != fnamemodify(fname, ':p')
|
if expand('%:p') != fnamemodify(fname, ':p')
|
||||||
echomsg 'different fname: "' .. expand('%:p') .. '" vs "' .. fnamemodify(fname, ':p') .. '"'
|
echomsg $"different fname: '{expand('%:p')}' vs '{fnamemodify(fname, ':p')}'"
|
||||||
augroup Termdebug
|
augroup Termdebug
|
||||||
" Always open a file read-only instead of showing the ATTENTION
|
" Always open a file read-only instead of showing the ATTENTION
|
||||||
" prompt, since it is unlikely we want to edit the file.
|
" prompt, since it is unlikely we want to edit the file.
|
||||||
@ -1646,17 +1642,17 @@ func s:HandleCursor(msg)
|
|||||||
augroup END
|
augroup END
|
||||||
if &modified
|
if &modified
|
||||||
" TODO: find existing window
|
" TODO: find existing window
|
||||||
exe 'split ' . fnameescape(fname)
|
exe $'split {fnameescape(fname)}'
|
||||||
let s:sourcewin = win_getid()
|
let s:sourcewin = win_getid()
|
||||||
call s:InstallWinbar(0)
|
call s:InstallWinbar(0)
|
||||||
else
|
else
|
||||||
exe 'edit ' . fnameescape(fname)
|
exe $'edit {fnameescape(fname)}'
|
||||||
endif
|
endif
|
||||||
augroup Termdebug
|
augroup Termdebug
|
||||||
au! SwapExists
|
au! SwapExists
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
exe lnum
|
exe $":{lnum}"
|
||||||
normal! zv
|
normal! zv
|
||||||
call sign_unplace('TermDebug', #{id: s:pc_id})
|
call sign_unplace('TermDebug', #{id: s:pc_id})
|
||||||
call sign_place(s:pc_id, 'TermDebug', 'debugPC', fname,
|
call sign_place(s:pc_id, 'TermDebug', 'debugPC', fname,
|
||||||
@ -1695,7 +1691,7 @@ func s:CreateBreakpoint(id, subid, enabled)
|
|||||||
let label = 'F+'
|
let label = 'F+'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call sign_define('debugBreakpoint' .. nr,
|
call sign_define($'debugBreakpoint{nr}',
|
||||||
\ #{text: slice(label, 0, 2),
|
\ #{text: slice(label, 0, 2),
|
||||||
\ texthl: hiName})
|
\ texthl: hiName})
|
||||||
endif
|
endif
|
||||||
@ -1713,7 +1709,7 @@ func s:HandleNewBreakpoint(msg, modifiedFlag)
|
|||||||
if a:msg =~ 'pending='
|
if a:msg =~ 'pending='
|
||||||
let nr = substitute(a:msg, '.*number=\"\([0-9.]*\)\".*', '\1', '')
|
let nr = substitute(a:msg, '.*number=\"\([0-9.]*\)\".*', '\1', '')
|
||||||
let target = substitute(a:msg, '.*pending=\"\([^"]*\)\".*', '\1', '')
|
let target = substitute(a:msg, '.*pending=\"\([^"]*\)\".*', '\1', '')
|
||||||
echomsg 'Breakpoint ' . nr . ' (' . target . ') pending.'
|
echomsg $'Breakpoint {nr} ({target}) pending.'
|
||||||
endif
|
endif
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -1758,9 +1754,9 @@ func s:HandleNewBreakpoint(msg, modifiedFlag)
|
|||||||
|
|
||||||
if bufloaded(fname)
|
if bufloaded(fname)
|
||||||
call s:PlaceSign(id, subid, entry)
|
call s:PlaceSign(id, subid, entry)
|
||||||
let posMsg = ' at line ' . lnum . '.'
|
let posMsg = $' at line {lnum}.'
|
||||||
else
|
else
|
||||||
let posMsg = ' in ' . fname . ' at line ' . lnum . '.'
|
let posMsg = $' in {fname} at line {lnum}.'
|
||||||
endif
|
endif
|
||||||
if !a:modifiedFlag
|
if !a:modifiedFlag
|
||||||
let actionTaken = 'created'
|
let actionTaken = 'created'
|
||||||
@ -1769,14 +1765,14 @@ func s:HandleNewBreakpoint(msg, modifiedFlag)
|
|||||||
else
|
else
|
||||||
let actionTaken = 'enabled'
|
let actionTaken = 'enabled'
|
||||||
endif
|
endif
|
||||||
echomsg 'Breakpoint ' . nr . ' ' . actionTaken . posMsg
|
echom $'Breakpoint {nr} {actionTaken}{posMsg}'
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func s:PlaceSign(id, subid, entry)
|
func s:PlaceSign(id, subid, entry)
|
||||||
let nr = printf('%d.%d', a:id, a:subid)
|
let nr = printf('%d.%d', a:id, a:subid)
|
||||||
call sign_place(s:Breakpoint2SignNumber(a:id, a:subid), 'TermDebug',
|
call sign_place(s:Breakpoint2SignNumber(a:id, a:subid), 'TermDebug',
|
||||||
\ 'debugBreakpoint' .. nr, a:entry['fname'],
|
\ $'debugBreakpoint{nr}', a:entry['fname'],
|
||||||
\ #{lnum: a:entry['lnum'], priority: 110})
|
\ #{lnum: a:entry['lnum'], priority: 110})
|
||||||
let a:entry['placed'] = 1
|
let a:entry['placed'] = 1
|
||||||
endfunc
|
endfunc
|
||||||
@ -1797,7 +1793,7 @@ func s:HandleBreakpointDelete(msg)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
unlet s:breakpoints[id]
|
unlet s:breakpoints[id]
|
||||||
echomsg 'Breakpoint ' . id . ' cleared.'
|
echomsg $'Breakpoint {id} cleared.'
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -1809,7 +1805,7 @@ func s:HandleProgramRun(msg)
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let s:pid = nr
|
let s:pid = nr
|
||||||
"call ch_log('Detected process ID: ' . s:pid)
|
" call ch_log($'Detected process ID: {s:pid}')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Handle a BufRead autocommand event: place any signs.
|
" Handle a BufRead autocommand event: place any signs.
|
||||||
|
Loading…
Reference in New Issue
Block a user