forked from aniani/vim
runtime(termdebug): Use string interpolation instead of string concat
closes: #14972 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
7c57940e3b
commit
83d0028026
193
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
vendored
193
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
vendored
@@ -148,9 +148,9 @@ enddef
|
||||
def Highlight(init: bool, old: string, new: string)
|
||||
var default = init ? 'default ' : ''
|
||||
if new ==# 'light' && old !=# 'light'
|
||||
exe "hi " .. default .. "debugPC term=reverse ctermbg=lightblue guibg=lightblue"
|
||||
exe $"hi {default}debugPC term=reverse ctermbg=lightblue guibg=lightblue"
|
||||
elseif new ==# 'dark' && old !=# 'dark'
|
||||
exe "hi " .. default .. "debugPC term=reverse ctermbg=darkblue guibg=darkblue"
|
||||
exe $"hi {default}debugPC term=reverse ctermbg=darkblue guibg=darkblue"
|
||||
endif
|
||||
enddef
|
||||
|
||||
@@ -183,17 +183,17 @@ def GetCommand(): list<string>
|
||||
enddef
|
||||
|
||||
def Echoerr(msg: string)
|
||||
echohl ErrorMsg | echom '[termdebug] ' .. msg | echohl None
|
||||
echohl ErrorMsg | echom $'[termdebug] {msg}' | echohl None
|
||||
enddef
|
||||
|
||||
def StartDebug(bang: bool, ...gdb_args: list<string>)
|
||||
# First argument is the command to debug, second core file or process ID.
|
||||
StartDebug_internal({'gdb_args': gdb_args, 'bang': bang})
|
||||
StartDebug_internal({gdb_args: gdb_args, bang: bang})
|
||||
enddef
|
||||
|
||||
def StartDebugCommand(bang: bool, ...args: list<string>)
|
||||
# First argument is the command to debug, rest are run arguments.
|
||||
StartDebug_internal({'gdb_args': [args[0]], 'proc_args': args[1 : ], 'bang': bang})
|
||||
StartDebug_internal({gdb_args: [args[0]], proc_args: args[1 : ], bang: bang})
|
||||
enddef
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ def StartDebug_internal(dict: dict<any>)
|
||||
endif
|
||||
var gdbcmd = GetCommand()
|
||||
if !executable(gdbcmd[0])
|
||||
Echoerr('Cannot execute debugger program "' .. gdbcmd[0] .. '"')
|
||||
Echoerr($'Cannot execute debugger program "{gdbcmd[0]}"')
|
||||
return
|
||||
endif
|
||||
|
||||
@@ -272,13 +272,13 @@ enddef
|
||||
|
||||
# Use when debugger didn't start or ended.
|
||||
def CloseBuffers()
|
||||
exe 'bwipe! ' .. ptybuf
|
||||
exe 'bwipe! ' .. commbuf
|
||||
exe $'bwipe! {ptybuf}'
|
||||
exe $'bwipe! {commbuf}'
|
||||
if asmbuf > 0 && bufexists(asmbuf)
|
||||
exe 'bwipe! ' .. asmbuf
|
||||
exe $'bwipe! {asmbuf}'
|
||||
endif
|
||||
if varbuf > 0 && bufexists(varbuf)
|
||||
exe 'bwipe! ' .. varbuf
|
||||
exe $'bwipe! {varbuf}'
|
||||
endif
|
||||
running = 0
|
||||
gdbwin = 0
|
||||
@@ -292,7 +292,8 @@ def CheckGdbRunning(): string
|
||||
gdbproc_status = job_status(gdbproc)
|
||||
endif
|
||||
if gdbproc == v:null || gdbproc_status !=# 'run'
|
||||
Echoerr(string(GetCommand()[0]) .. ' exited unexpectedly')
|
||||
var cmd_name = string(GetCommand()[0])
|
||||
Echoerr($'{cmd_name} exited unexpectedly')
|
||||
CloseBuffers()
|
||||
return ''
|
||||
endif
|
||||
@@ -313,7 +314,7 @@ def StartDebug_term(dict: dict<any>)
|
||||
if vvertical
|
||||
# Assuming the source code window will get a signcolumn, use two more
|
||||
# columns for that, thus one less for the terminal window.
|
||||
exe ":" .. (&columns / 2 - 1) .. "wincmd |"
|
||||
exe $":{(&columns / 2 - 1)}wincmd |"
|
||||
if allleft
|
||||
# use the whole left column
|
||||
wincmd H
|
||||
@@ -328,7 +329,7 @@ def StartDebug_term(dict: dict<any>)
|
||||
})
|
||||
if commbuf == 0
|
||||
Echoerr('Failed to open the communication terminal window')
|
||||
exe 'bwipe! ' .. ptybuf
|
||||
exe $'bwipe! {ptybuf}'
|
||||
return
|
||||
endif
|
||||
var commpty = job_info(term_getjob(commbuf))['tty_out']
|
||||
@@ -363,7 +364,7 @@ def StartDebug_term(dict: dict<any>)
|
||||
# Adding arguments requested by the user
|
||||
gdb_cmd += gdb_args
|
||||
|
||||
ch_log('executing "' .. join(gdb_cmd) .. '"')
|
||||
ch_log($'executing "{join(gdb_cmd)}"')
|
||||
gdbbuf = term_start(gdb_cmd, {
|
||||
term_name: 'gdb',
|
||||
term_finish: 'close',
|
||||
@@ -405,12 +406,12 @@ def StartDebug_term(dict: dict<any>)
|
||||
# ---- gdb started. Next, let's set the MI interface. ---
|
||||
# Set arguments to be run.
|
||||
if len(proc_args)
|
||||
term_sendkeys(gdbbuf, 'server set args ' .. join(proc_args) .. "\r")
|
||||
term_sendkeys(gdbbuf, $"server set args {join(proc_args)}\r")
|
||||
endif
|
||||
|
||||
# Connect gdb to the communication pty, using the GDB/MI interface.
|
||||
# Prefix "server" to avoid adding this to the history.
|
||||
term_sendkeys(gdbbuf, 'server new-ui mi ' .. commpty .. "\r")
|
||||
term_sendkeys(gdbbuf, $"server new-ui mi {commpty}\r")
|
||||
|
||||
# Wait for the response to show up, users may not notice the error and wonder
|
||||
# why the debugger doesn't work.
|
||||
@@ -456,7 +457,7 @@ def StartDebug_term(dict: dict<any>)
|
||||
return
|
||||
endif
|
||||
|
||||
job_setoptions(term_getjob(gdbbuf), {'exit_cb': function('EndTermDebug')})
|
||||
job_setoptions(term_getjob(gdbbuf), {exit_cb: function('EndTermDebug')})
|
||||
|
||||
# Set the filetype, this can be used to add mappings.
|
||||
set filetype=termdebug
|
||||
@@ -493,7 +494,7 @@ def StartDebug_prompt(dict: dict<any>)
|
||||
if vvertical
|
||||
# Assuming the source code window will get a signcolumn, use two more
|
||||
# columns for that, thus one less for the terminal window.
|
||||
exe ":" .. (&columns / 2 - 1) .. "wincmd |"
|
||||
exe $":{(&columns / 2 - 1)}wincmd |"
|
||||
endif
|
||||
|
||||
var gdb_args = get(dict, 'gdb_args', [])
|
||||
@@ -514,14 +515,14 @@ def StartDebug_prompt(dict: dict<any>)
|
||||
# Adding arguments requested by the user
|
||||
gdb_cmd += gdb_args
|
||||
|
||||
ch_log('executing "' .. join(gdb_cmd) .. '"')
|
||||
ch_log($'executing "{join(gdb_cmd)}"')
|
||||
gdbjob = job_start(gdb_cmd, {
|
||||
exit_cb: function('EndPromptDebug'),
|
||||
out_cb: function('GdbOutCallback'),
|
||||
})
|
||||
if job_status(gdbjob) != "run"
|
||||
Echoerr('Failed to start gdb')
|
||||
exe 'bwipe! ' .. promptbuf
|
||||
exe $'bwipe! {promptbuf}'
|
||||
return
|
||||
endif
|
||||
exe $'au BufUnload <buffer={promptbuf}> ++once ' ..
|
||||
@@ -547,16 +548,16 @@ def StartDebug_prompt(dict: dict<any>)
|
||||
endif
|
||||
ptywin = win_getid()
|
||||
var pty = job_info(term_getjob(ptybuf))['tty_out']
|
||||
SendCommand('tty ' .. pty)
|
||||
SendCommand($'tty {pty}')
|
||||
|
||||
# Since GDB runs in a prompt window, the environment has not been set to
|
||||
# match a terminal window, need to do that now.
|
||||
SendCommand('set env TERM = xterm-color')
|
||||
SendCommand('set env ROWS = ' .. winheight(ptywin))
|
||||
SendCommand('set env LINES = ' .. winheight(ptywin))
|
||||
SendCommand('set env COLUMNS = ' .. winwidth(ptywin))
|
||||
SendCommand('set env COLORS = ' .. &t_Co)
|
||||
SendCommand('set env VIM_TERMINAL = ' .. v:version)
|
||||
SendCommand($'set env ROWS = {winheight(ptywin)}')
|
||||
SendCommand($'set env LINES = {winheight(ptywin)}')
|
||||
SendCommand($'set env COLUMNS = {winwidth(ptywin)}')
|
||||
SendCommand($'set env COLORS = {&t_Co}')
|
||||
SendCommand($'set env VIM_TERMINAL = {v:version}')
|
||||
else
|
||||
# TODO: open a new terminal, get the tty name, pass on to gdb
|
||||
SendCommand('show inferior-tty')
|
||||
@@ -566,7 +567,7 @@ def StartDebug_prompt(dict: dict<any>)
|
||||
|
||||
# Set arguments to be run
|
||||
if len(proc_args)
|
||||
SendCommand('set args ' .. join(proc_args))
|
||||
SendCommand($'set args {join(proc_args)}')
|
||||
endif
|
||||
|
||||
StartDebugCommon(dict)
|
||||
@@ -576,7 +577,7 @@ enddef
|
||||
def StartDebugCommon(dict: dict<any>)
|
||||
# Sign used to highlight the line where the program has stopped.
|
||||
# There can be only one.
|
||||
sign_define('debugPC', {'linehl': 'debugPC'})
|
||||
sign_define('debugPC', {linehl: 'debugPC'})
|
||||
|
||||
# Install debugger commands in the text window.
|
||||
win_gotoid(sourcewin)
|
||||
@@ -610,11 +611,11 @@ enddef
|
||||
|
||||
# Send a command to gdb. "cmd" is the string without line terminator.
|
||||
def SendCommand(cmd: string)
|
||||
ch_log('sending to gdb: ' .. cmd)
|
||||
ch_log($'sending to gdb: {cmd}')
|
||||
if way == 'prompt'
|
||||
ch_sendraw(gdb_channel, cmd .. "\n")
|
||||
ch_sendraw(gdb_channel, $"{cmd}\n")
|
||||
else
|
||||
term_sendkeys(commbuf, cmd .. "\r")
|
||||
term_sendkeys(commbuf, $"{cmd}\r")
|
||||
endif
|
||||
enddef
|
||||
|
||||
@@ -642,7 +643,7 @@ enddef
|
||||
# This is global so that a user can create their mappings with this.
|
||||
def TermDebugSendCommand(cmd: string)
|
||||
if way == 'prompt'
|
||||
ch_sendraw(gdb_channel, cmd .. "\n")
|
||||
ch_sendraw(gdb_channel, $"{cmd}\n")
|
||||
else
|
||||
var do_continue = 0
|
||||
if !stopped
|
||||
@@ -651,7 +652,7 @@ def TermDebugSendCommand(cmd: string)
|
||||
sleep 10m
|
||||
endif
|
||||
# TODO: should we prepend CTRL-U to clear the command?
|
||||
term_sendkeys(gdbbuf, cmd .. "\r")
|
||||
term_sendkeys(gdbbuf, $"{cmd}\r")
|
||||
if do_continue
|
||||
ContinueCommand()
|
||||
endif
|
||||
@@ -668,7 +669,7 @@ def SendResumingCommand(cmd: string)
|
||||
ch_log('assume that program is running after this command')
|
||||
SendCommand(cmd)
|
||||
else
|
||||
ch_log('dropping command, program is running: ' .. cmd)
|
||||
ch_log($'dropping command, program is running: {cmd}')
|
||||
endif
|
||||
enddef
|
||||
|
||||
@@ -696,7 +697,7 @@ enddef
|
||||
|
||||
# Function called when gdb outputs text.
|
||||
def GdbOutCallback(channel: channel, text: string)
|
||||
ch_log('received from gdb: ' .. text)
|
||||
ch_log($'received from gdb: {text}')
|
||||
|
||||
# Disassembly messages need to be forwarded as-is.
|
||||
if parsing_disasm_msg > 0
|
||||
@@ -746,7 +747,7 @@ enddef
|
||||
# - change \\ to \
|
||||
def DecodeMessage(quotedText: string, literal: bool): string
|
||||
if quotedText[0] != '"'
|
||||
Echoerr('DecodeMessage(): missing quote in ' .. quotedText)
|
||||
Echoerr($'DecodeMessage(): missing quote in {quotedText}')
|
||||
return ''
|
||||
endif
|
||||
var msg = quotedText
|
||||
@@ -805,7 +806,7 @@ def EndTermDebug(job: any, status: any)
|
||||
endif
|
||||
|
||||
if bufexists(commbuf)
|
||||
exe 'bwipe! ' .. commbuf
|
||||
exe $'bwipe! {commbuf}'
|
||||
endif
|
||||
gdbwin = 0
|
||||
EndDebugCommon()
|
||||
@@ -815,13 +816,13 @@ def EndDebugCommon()
|
||||
var curwinid = win_getid()
|
||||
|
||||
if bufexists(ptybuf)
|
||||
exe 'bwipe! ' .. ptybuf
|
||||
exe $'bwipe! {ptybuf}'
|
||||
endif
|
||||
if bufexists(asmbuf)
|
||||
exe 'bwipe! ' .. asmbuf
|
||||
exe $'bwipe! {asmbuf}'
|
||||
endif
|
||||
if bufexists(varbuf)
|
||||
exe 'bwipe! ' .. varbuf
|
||||
exe $'bwipe! {varbuf}'
|
||||
endif
|
||||
running = 0
|
||||
|
||||
@@ -830,7 +831,7 @@ def EndDebugCommon()
|
||||
var was_buf = bufnr()
|
||||
for bufnr in signcolumn_buflist
|
||||
if bufexists(bufnr)
|
||||
exe ":" .. bufnr .. "buf"
|
||||
exe $":{bufnr}buf"
|
||||
if exists('b:save_signcolumn')
|
||||
&signcolumn = b:save_signcolumn
|
||||
unlet b:save_signcolumn
|
||||
@@ -838,7 +839,7 @@ def EndDebugCommon()
|
||||
endif
|
||||
endfor
|
||||
if bufexists(was_buf)
|
||||
exe ":" .. was_buf .. "buf"
|
||||
exe $":{was_buf}buf"
|
||||
endif
|
||||
|
||||
DeleteCommands()
|
||||
@@ -872,7 +873,7 @@ def EndPromptDebug(job: any, status: any)
|
||||
endif
|
||||
|
||||
if bufexists(promptbuf)
|
||||
exe 'bwipe! ' .. promptbuf
|
||||
exe $'bwipe! {promptbuf}'
|
||||
endif
|
||||
|
||||
EndDebugCommon()
|
||||
@@ -904,10 +905,10 @@ def HandleDisasmMsg(msg: string)
|
||||
set nomodified
|
||||
set filetype=asm
|
||||
|
||||
var lnum = search('^' .. asm_addr)
|
||||
var lnum = search($'^{asm_addr}')
|
||||
if lnum != 0
|
||||
sign_unplace('TermDebug', {'id': asm_id})
|
||||
sign_place(asm_id, 'TermDebug', 'debugPC', '%', {'lnum': lnum})
|
||||
sign_unplace('TermDebug', {id: asm_id})
|
||||
sign_place(asm_id, 'TermDebug', 'debugPC', '%', {lnum: lnum})
|
||||
endif
|
||||
|
||||
win_gotoid(curwinid)
|
||||
@@ -966,8 +967,8 @@ def HandleVariablesMsg(msg: string)
|
||||
if win_gotoid(varwin)
|
||||
silent! :%delete _
|
||||
var spaceBuffer = 20
|
||||
setline(1, 'Type' ..
|
||||
repeat(' ', 16) .. 'Name' .. repeat(' ', 16) .. 'Value')
|
||||
var spaces = repeat(' ', 16)
|
||||
setline(1, $'Type{spaces}Name{spaces}Value')
|
||||
var cnt = 1
|
||||
var capture = '{name=".\{-}",\%(arg=".\{-}",\)\{0,1\}type=".\{-}"\%(,value=".\{-}"\)\{0,1\}}'
|
||||
var varinfo = matchstr(msg, capture, 0, cnt)
|
||||
@@ -1251,9 +1252,8 @@ def Until(at: string)
|
||||
ch_log('assume that program is running after this command')
|
||||
|
||||
# Use the fname:lnum format
|
||||
var AT = empty(at) ?
|
||||
fnameescape(expand('%:p')) .. ':' .. line('.') : at
|
||||
SendCommand('-exec-until ' .. AT)
|
||||
var AT = empty(at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : at
|
||||
SendCommand($'-exec-until {AT}')
|
||||
else
|
||||
ch_log('dropping command, program is running: exec-until')
|
||||
endif
|
||||
@@ -1271,16 +1271,15 @@ def SetBreakpoint(at: string, tbreak=false)
|
||||
endif
|
||||
|
||||
# Use the fname:lnum format, older gdb can't handle --source.
|
||||
var AT = empty(at) ?
|
||||
fnameescape(expand('%:p')) .. ':' .. line('.') : at
|
||||
var AT = empty(at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : at
|
||||
var cmd = ''
|
||||
if tbreak
|
||||
cmd = '-break-insert -t ' .. AT
|
||||
cmd = $'-break-insert -t {AT}'
|
||||
else
|
||||
cmd = '-break-insert ' .. AT
|
||||
cmd = $'-break-insert {AT}'
|
||||
endif
|
||||
# OK
|
||||
# echom "cmsd: " .. cmd
|
||||
# echom $"cmsd: {cmd}"
|
||||
SendCommand(cmd)
|
||||
if do_continue
|
||||
ContinueCommand()
|
||||
@@ -1297,7 +1296,7 @@ def ClearBreakpoint()
|
||||
for id in breakpoint_locations[bploc]
|
||||
if has_key(breakpoints, id)
|
||||
# Assume this always works, the reply is simply "^done".
|
||||
SendCommand('-break-delete ' .. id)
|
||||
SendCommand($'-break-delete {id}')
|
||||
for subid in keys(breakpoints[id])
|
||||
sign_unplace('TermDebug',
|
||||
{id: Breakpoint2SignNumber(id, str2nr(subid))})
|
||||
@@ -1315,18 +1314,18 @@ def ClearBreakpoint()
|
||||
if empty(breakpoint_locations[bploc])
|
||||
remove(breakpoint_locations, bploc)
|
||||
endif
|
||||
echomsg 'Breakpoint ' .. nr .. ' cleared from line ' .. lnum .. '.'
|
||||
echomsg $'Breakpoint {nr} cleared from line {lnum}.'
|
||||
else
|
||||
Echoerr('Internal error trying to remove breakpoint at line ' .. lnum .. '!')
|
||||
Echoerr($'Internal error trying to remove breakpoint at line {lnum}!')
|
||||
endif
|
||||
else
|
||||
echomsg 'No breakpoint to remove at line ' .. lnum .. '.'
|
||||
echomsg $'No breakpoint to remove at line {lnum}.'
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Run(args: string)
|
||||
if args != ''
|
||||
SendResumingCommand('-exec-arguments ' .. args)
|
||||
SendResumingCommand($'-exec-arguments {args}')
|
||||
endif
|
||||
SendResumingCommand('-exec-run')
|
||||
enddef
|
||||
@@ -1340,13 +1339,13 @@ def Frame(arg: string)
|
||||
# already parsed and allows for more formats
|
||||
if arg =~ '^\d\+$' || arg == ''
|
||||
# specify frame by number
|
||||
SendCommand('-interpreter-exec mi "frame ' .. arg .. '"')
|
||||
SendCommand($'-interpreter-exec mi "frame {arg}"')
|
||||
elseif arg =~ '^0x[0-9a-fA-F]\+$'
|
||||
# specify frame by stack address
|
||||
SendCommand('-interpreter-exec mi "frame address ' .. arg .. '"')
|
||||
SendCommand($'-interpreter-exec mi "frame address {arg}"')
|
||||
else
|
||||
# specify frame by function name
|
||||
SendCommand('-interpreter-exec mi "frame function ' .. arg .. '"')
|
||||
SendCommand($'-interpreter-exec mi "frame function {arg}"')
|
||||
endif
|
||||
enddef
|
||||
|
||||
@@ -1373,14 +1372,14 @@ def SendEval(expr: string)
|
||||
var expr_escaped = expr
|
||||
->substitute('\\', '\\\\', 'g')
|
||||
->substitute('"', '\\"', 'g')
|
||||
SendCommand('-data-evaluate-expression "' .. expr_escaped .. '"')
|
||||
SendCommand($'-data-evaluate-expression "{expr_escaped}"')
|
||||
evalexpr = exprLHS
|
||||
enddef
|
||||
|
||||
# :Evaluate - evaluate what is specified / under the cursor
|
||||
def Evaluate(range: number, arg: string)
|
||||
var expr = GetEvaluationExpression(range, arg)
|
||||
#echom "expr:" .. expr
|
||||
#echom $"expr: {expr}"
|
||||
ignoreEvalError = 0
|
||||
SendEval(expr)
|
||||
enddef
|
||||
@@ -1451,19 +1450,19 @@ def HandleEvaluate(msg: string)
|
||||
\ ->substitute(NullRepl, '\\000', 'g')
|
||||
if evalFromBalloonExpr
|
||||
if evalFromBalloonExprResult == ''
|
||||
evalFromBalloonExprResult = evalexpr .. ': ' .. value
|
||||
evalFromBalloonExprResult = $'{evalexpr}: {value}'
|
||||
else
|
||||
evalFromBalloonExprResult ..= ' = ' .. value
|
||||
evalFromBalloonExprResult ..= $' = {value}'
|
||||
endif
|
||||
balloon_show(evalFromBalloonExprResult)
|
||||
else
|
||||
echomsg '"' .. evalexpr .. '": ' .. value
|
||||
echomsg $'"{evalexpr}": {value}'
|
||||
endif
|
||||
|
||||
if evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$'
|
||||
# Looks like a pointer, also display what it points to.
|
||||
ignoreEvalError = 1
|
||||
SendEval('*' .. evalexpr)
|
||||
SendEval($'*{evalexpr}')
|
||||
else
|
||||
evalFromBalloonExpr = 0
|
||||
endif
|
||||
@@ -1537,7 +1536,7 @@ def GotoAsmwinOrCreateIt()
|
||||
# 60 is approx spaceBuffer * 3
|
||||
if winwidth(0) > (78 + 60)
|
||||
mdf = 'vert'
|
||||
exe mdf .. ' ' .. ':60' .. 'new'
|
||||
exe $'{mdf} :60new'
|
||||
else
|
||||
exe 'rightbelow new'
|
||||
endif
|
||||
@@ -1556,7 +1555,7 @@ def GotoAsmwinOrCreateIt()
|
||||
setlocal modifiable
|
||||
|
||||
if asmbuf > 0 && bufexists(asmbuf)
|
||||
exe 'buffer' .. asmbuf
|
||||
exe $'buffer {asmbuf}'
|
||||
elseif empty(glob('Termdebug-asm-listing'))
|
||||
silent file Termdebug-asm-listing
|
||||
asmbuf = bufnr('Termdebug-asm-listing')
|
||||
@@ -1567,19 +1566,19 @@ def GotoAsmwinOrCreateIt()
|
||||
endif
|
||||
|
||||
if mdf != 'vert' && GetDisasmWindowHeight() > 0
|
||||
exe 'resize ' .. GetDisasmWindowHeight()
|
||||
exe $'resize {GetDisasmWindowHeight()}'
|
||||
endif
|
||||
endif
|
||||
|
||||
if asm_addr != ''
|
||||
var lnum = search('^' .. asm_addr)
|
||||
var lnum = search($'^{asm_addr}')
|
||||
if lnum == 0
|
||||
if stopped
|
||||
SendCommand('disassemble $pc')
|
||||
endif
|
||||
else
|
||||
sign_unplace('TermDebug', {'id': asm_id})
|
||||
sign_place(asm_id, 'TermDebug', 'debugPC', '%', {'lnum': lnum})
|
||||
sign_unplace('TermDebug', {id: asm_id})
|
||||
sign_place(asm_id, 'TermDebug', 'debugPC', '%', {lnum: lnum})
|
||||
endif
|
||||
endif
|
||||
enddef
|
||||
@@ -1612,7 +1611,7 @@ def GotoVariableswinOrCreateIt()
|
||||
# 60 is approx spaceBuffer * 3
|
||||
if winwidth(0) > (78 + 60)
|
||||
mdf = 'vert'
|
||||
exe mdf .. ' ' .. ':60' .. 'new'
|
||||
exe $'{mdf} :60new'
|
||||
else
|
||||
exe 'rightbelow new'
|
||||
endif
|
||||
@@ -1630,7 +1629,7 @@ def GotoVariableswinOrCreateIt()
|
||||
setlocal modifiable
|
||||
|
||||
if varbuf > 0 && bufexists(varbuf)
|
||||
exe 'buffer' .. varbuf
|
||||
exe $'buffer {varbuf}'
|
||||
elseif empty(glob('Termdebug-variables-listing'))
|
||||
silent file Termdebug-variables-listing
|
||||
varbuf = bufnr('Termdebug-variables-listing')
|
||||
@@ -1641,7 +1640,7 @@ def GotoVariableswinOrCreateIt()
|
||||
endif
|
||||
|
||||
if mdf != 'vert' && GetVariablesWindowHeight() > 0
|
||||
exe 'resize ' .. GetVariablesWindowHeight()
|
||||
exe $'resize {GetVariablesWindowHeight()}'
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -1680,12 +1679,12 @@ def HandleCursor(msg: string)
|
||||
var curwinid = win_getid()
|
||||
var lnum = 0
|
||||
if win_gotoid(asmwin)
|
||||
lnum = search('^' .. asm_addr)
|
||||
lnum = search($'^{asm_addr}')
|
||||
if lnum == 0
|
||||
SendCommand('disassemble $pc')
|
||||
else
|
||||
sign_unplace('TermDebug', {'id': asm_id})
|
||||
sign_place(asm_id, 'TermDebug', 'debugPC', '%', {'lnum': lnum})
|
||||
sign_unplace('TermDebug', {id: asm_id})
|
||||
sign_place(asm_id, 'TermDebug', 'debugPC', '%', {lnum: lnum})
|
||||
endif
|
||||
|
||||
win_gotoid(curwinid)
|
||||
@@ -1702,7 +1701,7 @@ def HandleCursor(msg: string)
|
||||
if lnum =~ '^[0-9]*$'
|
||||
GotoSourcewinOrCreateIt()
|
||||
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
|
||||
# Always open a file read-only instead of showing the ATTENTION
|
||||
# prompt, since it is unlikely we want to edit the file.
|
||||
@@ -1714,19 +1713,19 @@ def HandleCursor(msg: string)
|
||||
augroup END
|
||||
if &modified
|
||||
# TODO: find existing window
|
||||
exe 'split ' .. fnameescape(fname)
|
||||
exe $'split {fnameescape(fname)}'
|
||||
sourcewin = win_getid()
|
||||
call InstallWinbar(0)
|
||||
else
|
||||
exe 'edit ' .. fnameescape(fname)
|
||||
exe $'edit {fnameescape(fname)}'
|
||||
endif
|
||||
augroup Termdebug
|
||||
au! SwapExists
|
||||
augroup END
|
||||
endif
|
||||
exe ":" .. lnum
|
||||
exe $":{lnum}"
|
||||
normal! zv
|
||||
sign_unplace('TermDebug', {'id': pc_id})
|
||||
sign_unplace('TermDebug', {id: pc_id})
|
||||
sign_place(pc_id, 'TermDebug', 'debugPC', fname,
|
||||
{lnum: str2nr(lnum), priority: 110})
|
||||
if !exists('b:save_signcolumn')
|
||||
@@ -1736,7 +1735,7 @@ def HandleCursor(msg: string)
|
||||
setlocal signcolumn=yes
|
||||
endif
|
||||
elseif !stopped || fname != ''
|
||||
sign_unplace('TermDebug', {'id': pc_id})
|
||||
sign_unplace('TermDebug', {id: pc_id})
|
||||
endif
|
||||
|
||||
win_gotoid(wid)
|
||||
@@ -1762,7 +1761,7 @@ def CreateBreakpoint(id: number, subid: number, enabled: string)
|
||||
label = 'F+'
|
||||
endif
|
||||
endif
|
||||
sign_define('debugBreakpoint' .. nr,
|
||||
sign_define($'debugBreakpoint{nr}',
|
||||
{text: slice(label, 0, 2),
|
||||
texthl: hiName})
|
||||
endif
|
||||
@@ -1783,7 +1782,7 @@ def HandleNewBreakpoint(msg: string, modifiedFlag: any)
|
||||
if msg =~ 'pending='
|
||||
nr = substitute(msg, '.*number=\"\([0-9.]*\)\".*', '\1', '')
|
||||
var target = substitute(msg, '.*pending=\"\([^"]*\)\".*', '\1', '')
|
||||
echomsg 'Breakpoint ' .. nr .. ' (' .. target .. ') pending.'
|
||||
echomsg $'Breakpoint {nr} ({target}) pending.'
|
||||
endif
|
||||
return
|
||||
endif
|
||||
@@ -1831,9 +1830,9 @@ def HandleNewBreakpoint(msg: string, modifiedFlag: any)
|
||||
var posMsg = ''
|
||||
if bufloaded(fname)
|
||||
PlaceSign(id, subid, entry)
|
||||
posMsg = ' at line ' .. lnum .. '.'
|
||||
posMsg = $' at line {lnum}.'
|
||||
else
|
||||
posMsg = ' in ' .. fname .. ' at line ' .. lnum .. '.'
|
||||
posMsg = $' in {fname} at line {lnum}.'
|
||||
endif
|
||||
var actionTaken = ''
|
||||
if !modifiedFlag
|
||||
@@ -1843,7 +1842,7 @@ def HandleNewBreakpoint(msg: string, modifiedFlag: any)
|
||||
else
|
||||
actionTaken = 'enabled'
|
||||
endif
|
||||
echom 'Breakpoint ' .. nr .. ' ' .. actionTaken .. posMsg
|
||||
echom $'Breakpoint {nr} {actionTaken}{posMsg}'
|
||||
endfor
|
||||
enddef
|
||||
|
||||
@@ -1851,7 +1850,7 @@ enddef
|
||||
def PlaceSign(id: number, subid: number, entry: dict<any>)
|
||||
var nr = printf('%d.%d', id, subid)
|
||||
sign_place(Breakpoint2SignNumber(id, subid), 'TermDebug',
|
||||
'debugBreakpoint' .. nr, entry['fname'],
|
||||
$'debugBreakpoint{nr}', entry['fname'],
|
||||
{lnum: entry['lnum'], priority: 110})
|
||||
entry['placed'] = 1
|
||||
enddef
|
||||
@@ -1867,12 +1866,12 @@ def HandleBreakpointDelete(msg: string)
|
||||
for [subid, entry] in items(breakpoints[id])
|
||||
if has_key(entry, 'placed')
|
||||
sign_unplace('TermDebug',
|
||||
{'id': Breakpoint2SignNumber(str2nr(id), str2nr(subid))})
|
||||
{id: Breakpoint2SignNumber(str2nr(id), str2nr(subid))})
|
||||
remove(entry, 'placed')
|
||||
endif
|
||||
endfor
|
||||
remove(breakpoints, id)
|
||||
echomsg 'Breakpoint ' .. id .. ' cleared.'
|
||||
echomsg $'Breakpoint {id} cleared.'
|
||||
endif
|
||||
enddef
|
||||
|
||||
@@ -1884,7 +1883,7 @@ def HandleProgramRun(msg: string)
|
||||
return
|
||||
endif
|
||||
pid = nr
|
||||
ch_log('Detected process ID: ' .. pid)
|
||||
ch_log($'Detected process ID: {pid}')
|
||||
enddef
|
||||
|
||||
# Handle a BufRead autocommand event: place any signs.
|
||||
|
Reference in New Issue
Block a user