From 29e05cfb7ecd2abeac397c2ef2466166d18e1f41 Mon Sep 17 00:00:00 2001 From: Yinzuo Jiang Date: Fri, 14 Jun 2024 16:37:38 +0800 Subject: vim-patch:partial:9.1.0482: termdebug plugin needs more love (#29329) Problem: termdebug plugin needs more love Solution: start with some more Vim9 refactoring to improve maintenance and readability (Ubaldo Tiberi) List of Changes and the Reasoning Behind Them: 1) Introduction of InitScriptVariables() Function: Reasoning: This function has been introduced to ensure that when you open and close Termdebug, and then open it again, there are no leftover script variable values from the previous session. Leftover values could potentially cause issues. The goal is for each Termdebug session to be independent of previous sessions. At startup, all script variables are initialized. The only exception is g:termdebug_loaded located at the very beginning of the script to prevent sourcing the script twice. The variables are declared at script level and defined in InitScriptVariables(). 2) More Descriptive Variable Names: Reasoning: The names of variables have been made more comprehensive. Almost every Termdebug buffer now has a variable to indicate its name and another variable to indicate its number, improving code readability and maintainability. Due to the latest discussion around the &mousemodel option save/restore mechanism, perhaps some other variables shall be prepended with saved_. 3) Consistent Naming for GDB Terminal Buffers: Reasoning: The name of the GDB terminal buffer now matches the name of the GDB program being used, e.g., 'gdb', 'mygdb', 'arm-eabi-none-gdb', etc. This ensures clarity and consistency in identifying buffers. 4) Other minor improvements: Moved EchoErr() on top, added another test, some refactoring, mainly changed several 0 and 1 to true and false closes: vim/vim#14980 https://github.com/vim/vim/commit/ef8eab86e29091eaff0d3fb0bc3f7c90f468f6aa Co-authored-by: Ubaldo Tiberi --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 125 +++++++++++---------- 1 file changed, 63 insertions(+), 62 deletions(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index f78a082cb7..9d5d3f5b96 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -44,8 +44,13 @@ " - job_info && term_getjob -> nvim_get_chan_info " - balloon -> vim.lsp.util.open_floating_preview +func s:Echoerr(msg) + echohl ErrorMsg | echom '[termdebug] ' .. a:msg | echohl None +endfunc + " In case this gets sourced twice. if exists(':Termdebug') + call s:Echoerr('Termdebug already loaded.') finish endif @@ -67,8 +72,8 @@ command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand( let s:pc_id = 12 let s:asm_id = 13 let s:break_id = 14 " breakpoint number is added to this -let s:stopped = 1 -let s:running = 0 +let s:stopped = v:true +let s:running = v:false let s:parsing_disasm_msg = 0 let s:asm_lines = [] @@ -121,10 +126,6 @@ func s:GetCommand() return type(cmd) == v:t_list ? copy(cmd) : [cmd] endfunc -func s:Echoerr(msg) - echohl ErrorMsg | echom '[termdebug] ' .. a:msg | echohl None -endfunc - func s:StartDebug(bang, ...) " First argument is the command to debug, second core file or process ID. call s:StartDebug_internal({'gdb_args': a:000, 'bang': a:bang}) @@ -149,9 +150,9 @@ func s:StartDebug_internal(dict) let s:ptywin = 0 let s:pid = 0 let s:asmwin = 0 - let s:asmbuf = 0 + let s:asmbufnr = 0 let s:varwin = 0 - let s:varbuf = 0 + let s:varbufnr = 0 if exists('#User#TermdebugStartPre') doauto User TermdebugStartPre @@ -168,7 +169,7 @@ func s:StartDebug_internal(dict) let s:signcolumn_buflist = [bufnr()] let s:save_columns = 0 - let s:allleft = 0 + let s:allleft = v:false let wide = 0 if exists('g:termdebug_config') let wide = get(g:termdebug_config, 'wide', 0) @@ -181,11 +182,11 @@ func s:StartDebug_internal(dict) let &columns = wide " If we make the Vim window wider, use the whole left half for the debug " windows. - let s:allleft = 1 + let s:allleft = v:true endif - let s:vertical = 1 + let s:vertical = v:true else - let s:vertical = 0 + let s:vertical = v:false endif " Override using a terminal window by setting g:termdebug_use_prompt to 1. @@ -226,24 +227,24 @@ endfunc " Use when debugger didn't start or ended. func s:CloseBuffers() - exe 'bwipe! ' . s:ptybuf - if s:asmbuf > 0 && bufexists(s:asmbuf) - exe 'bwipe! ' . s:asmbuf + exe 'bwipe! ' . s:ptybufnr + if s:asmbufnr > 0 && bufexists(s:asmbufnr) + exe 'bwipe! ' . s:asmbufnr endif - if s:varbuf > 0 && bufexists(s:varbuf) - exe 'bwipe! ' . s:varbuf + if s:varbufnr > 0 && bufexists(s:varbufnr) + exe 'bwipe! ' . s:varbufnr endif - let s:running = 0 + let s:running = v:false unlet! s:gdbwin endfunc -func s:CheckGdbRunning() +func s:IsGdbStarted() if !s:gdb_running call s:Echoerr(string(s:GetCommand()[0]) . ' exited unexpectedly') call s:CloseBuffers() - return '' + return v:false endif - return 'ok' + return v:true endfunc " Open a terminal window without a job, to run the debugged program in. @@ -258,7 +259,7 @@ func s:StartDebug_term(dict) return endif let pty_job_info = nvim_get_chan_info(s:pty_job_id) - let s:ptybuf = pty_job_info['buffer'] + let s:ptybufnr = pty_job_info['buffer'] let pty = pty_job_info['pty'] let s:ptywin = win_getid() if s:vertical @@ -279,11 +280,11 @@ func s:StartDebug_term(dict) " hide terminal buffer if s:comm_job_id == 0 call s:Echoerr('Invalid argument (or job table is full) while opening communication terminal window') - exe 'bwipe! ' . s:ptybuf + exe 'bwipe! ' . s:ptybufnr return elseif s:comm_job_id == -1 call s:Echoerr('Failed to open the communication terminal window') - exe 'bwipe! ' . s:ptybuf + exe 'bwipe! ' . s:ptybufnr return endif let comm_job_info = nvim_get_chan_info(s:comm_job_id) @@ -324,7 +325,7 @@ func s:StartDebug_term(dict) let s:gdb_job_id = termopen(gdb_cmd, {'on_exit': function('s:EndTermDebug')}) if s:gdb_job_id == 0 call s:Echoerr('Invalid argument (or job table is full) while opening gdb terminal window') - exe 'bwipe! ' . s:ptybuf + exe 'bwipe! ' . s:ptybufnr return elseif s:gdb_job_id == -1 call s:Echoerr('Failed to open the gdb terminal window') @@ -334,18 +335,18 @@ func s:StartDebug_term(dict) let s:gdb_running = v:true let s:starting = v:true let gdb_job_info = nvim_get_chan_info(s:gdb_job_id) - let s:gdbbuf = gdb_job_info['buffer'] + let s:gdbbufnr = gdb_job_info['buffer'] let s:gdbwin = win_getid() " Wait for the "startupdone" message before sending any commands. let try_count = 0 while 1 - if s:CheckGdbRunning() != 'ok' + if !s:IsGdbStarted() return endif for lnum in range(1, 200) - if get(getbufline(s:gdbbuf, lnum), 0, '') =~ 'startupdone' + if get(getbufline(s:gdbbufnr, lnum), 0, '') =~ 'startupdone' let try_count = 9999 break endif @@ -371,14 +372,14 @@ func s:StartDebug_term(dict) " why the debugger doesn't work. let try_count = 0 while 1 - if s:CheckGdbRunning() != 'ok' + if !s:IsGdbStarted() return endif let response = '' for lnum in range(1, 200) - let line1 = get(getbufline(s:gdbbuf, lnum), 0, '') - let line2 = get(getbufline(s:gdbbuf, lnum + 1), 0, '') + let line1 = get(getbufline(s:gdbbufnr, lnum), 0, '') + let line2 = get(getbufline(s:gdbbufnr, lnum + 1), 0, '') if line1 =~ 'new-ui mi ' " response can be in the same line or the next line let response = line1 . line2 @@ -472,7 +473,7 @@ func s:StartDebug_prompt(dict) \ }) if s:gdbjob == 0 call s:Echoerr('Invalid argument (or job table is full) while starting gdb job') - exe 'bwipe! ' . s:ptybuf + exe 'bwipe! ' . s:ptybufnr return elseif s:gdbjob == -1 call s:Echoerr('Failed to start the gdb job') @@ -481,7 +482,7 @@ func s:StartDebug_prompt(dict) endif exe $'au BufUnload ++once call jobstop(s:gdbjob)' - let s:ptybuf = 0 + let s:ptybufnr = 0 if has('win32') " MS-Windows: run in a new console window for maximum compatibility call s:SendCommand('set new-console on') @@ -498,7 +499,7 @@ func s:StartDebug_prompt(dict) return endif let pty_job_info = nvim_get_chan_info(s:pty_job_id) - let s:ptybuf = pty_job_info['buffer'] + let s:ptybufnr = pty_job_info['buffer'] let pty = pty_job_info['pty'] let s:ptywin = win_getid() call s:SendCommand('tty ' . pty) @@ -602,7 +603,7 @@ endfunc func s:SendResumingCommand(cmd) if s:stopped " reset s:stopped here, it may take a bit of time before we get a response - let s:stopped = 0 + let s:stopped = v:false " call ch_log('assume that program is running after this command') call s:SendCommand(a:cmd) " else @@ -776,16 +777,16 @@ endfunc func s:EndDebugCommon() let curwinid = win_getid() - if exists('s:ptybuf') && s:ptybuf - exe 'bwipe! ' . s:ptybuf + if exists('s:ptybufnr') && s:ptybufnr + exe 'bwipe! ' . s:ptybufnr endif - if s:asmbuf > 0 && bufexists(s:asmbuf) - exe 'bwipe! ' . s:asmbuf + if s:asmbufnr > 0 && bufexists(s:asmbufnr) + exe 'bwipe! ' . s:asmbufnr endif - if s:varbuf > 0 && bufexists(s:varbuf) - exe 'bwipe! ' . s:varbuf + if s:varbufnr > 0 && bufexists(s:varbufnr) + exe 'bwipe! ' . s:varbufnr endif - let s:running = 0 + let s:running = v:false " Restore 'signcolumn' in all buffers for which it was set. call win_gotoid(s:sourcewin) @@ -1186,7 +1187,7 @@ endfunc func s:Until(at) if s:stopped " reset s:stopped here, it may take a bit of time before we get a response - let s:stopped = 0 + let s:stopped = v:false " call ch_log('assume that program is running after this command') " Use the fname:lnum format let at = empty(a:at) ? @@ -1322,9 +1323,9 @@ func s:Evaluate(range, arg) return endif let expr = s:GetEvaluationExpression(a:range, a:arg) - let s:evalFromBalloonExpr = 1 + let s:evalFromBalloonExpr = v:true let s:evalFromBalloonExprResult = '' - let s:ignoreEvalError = 0 + let s:ignoreEvalError = v:false call s:SendEval(expr) endfunc @@ -1343,12 +1344,12 @@ func s:GetEvaluationExpression(range, arg) let expr = s:CleanupExpr(@v) call setpos('.', pos) call setreg('v', reg, regt) - let s:evalFromBalloonExpr = 1 + let s:evalFromBalloonExpr = v:true else " no evaluation provided: get from C-expression under cursor " TODO: allow filetype specific lookup #9057 let expr = expand('') - let s:evalFromBalloonExpr = 1 + let s:evalFromBalloonExpr = v:true endif return expr endfunc @@ -1376,8 +1377,8 @@ func s:CleanupExpr(expr) return expr endfunc -let s:ignoreEvalError = 0 -let s:evalFromBalloonExpr = 0 +let s:ignoreEvalError = v:false +let s:evalFromBalloonExpr = v:false let s:evalFromBalloonExprResult = '' let s:eval_float_win_id = -1 @@ -1419,7 +1420,7 @@ func s:HandleEvaluate(msg) if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$' " Looks like a pointer, also display what it points to. - let s:ignoreEvalError = 1 + let s:ignoreEvalError = v:true call s:SendEval('*' . s:evalexpr) endif endfunc @@ -1428,8 +1429,8 @@ endfunc func s:HandleError(msg) if s:ignoreEvalError " Result of s:SendEval() failed, ignore. - let s:ignoreEvalError = 0 - let s:evalFromBalloonExpr = 0 + let s:ignoreEvalError = v:false + let s:evalFromBalloonExpr = v:false return endif let msgVal = substitute(a:msg, '.*msg="\(.*\)"', '\1', '') @@ -1489,11 +1490,11 @@ func s:GotoAsmwinOrCreateIt() setlocal signcolumn=no setlocal modifiable - if s:asmbuf > 0 && bufexists(s:asmbuf) - exe 'buffer' . s:asmbuf + if s:asmbufnr > 0 && bufexists(s:asmbufnr) + exe 'buffer' . s:asmbufnr elseif empty(glob('Termdebug-asm-listing')) silent file Termdebug-asm-listing - let s:asmbuf = bufnr('Termdebug-asm-listing') + let s:asmbufnr = bufnr('Termdebug-asm-listing') else call s:Echoerr("You have a file/folder named 'Termdebug-asm-listing'. \ Please exit and rename it because Termdebug may not work as expected.") @@ -1561,11 +1562,11 @@ func s:GotoVariableswinOrCreateIt() setlocal signcolumn=no setlocal modifiable - if s:varbuf > 0 && bufexists(s:varbuf) - exe 'buffer' . s:varbuf + if s:varbufnr > 0 && bufexists(s:varbufnr) + exe 'buffer' . s:varbufnr elseif empty(glob('Termdebug-variables-listing')) silent file Termdebug-variables-listing - let s:varbuf = bufnr('Termdebug-variables-listing') + let s:varbufnr = bufnr('Termdebug-variables-listing') else call s:Echoerr("You have a file/folder named 'Termdebug-variables-listing'. \ Please exit and rename it because Termdebug may not work as expected.") @@ -1588,14 +1589,14 @@ func s:HandleCursor(msg) if a:msg =~ '^\*stopped' "call ch_log('program stopped') - let s:stopped = 1 + let s:stopped = v:true if a:msg =~ '^\*stopped,reason="exited-normally"' - let s:running = 0 + let s:running = v:false endif elseif a:msg =~ '^\*running' "call ch_log('program running') - let s:stopped = 0 - let s:running = 1 + let s:stopped = v:false + let s:running = v:true endif if a:msg =~ 'fullname=' -- cgit From 2791fd4e1722fd45fa0f4261879046e8d397645a Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 18 Jun 2024 19:44:46 +0200 Subject: vim-patch:26de90c: runtime(nohlsearch): include the the simple nohlsearch package fixes: vim/vim#15039 closes: vim/vim#15042 https://github.com/vim/vim/commit/26de90c6312cf16d7a4f2b6942befb4e1f14b960 Co-authored-by: Maxim Kim --- runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim new file mode 100644 index 0000000000..6cfe813cfa --- /dev/null +++ b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim @@ -0,0 +1,14 @@ +" nohlsearch.vim: Auto turn off hlsearch +" Last Change: 2024-06-18 +" Maintainer: Maxim Kim +" +" turn off hlsearch after: +" - doing nothing for 'updatetime' +" - getting into insert mode +augroup nohlsearch + au! + noremap (nohlsearch) nohlsearch + noremap! (nohlsearch) execute('nohlsearch')[-1] + au CursorHold * call feedkeys("\(nohlsearch)", 'm') + au InsertEnter * call feedkeys("\(nohlsearch)", 'm') +augroup END -- cgit From b48192af37aa39d55e73420e3838cb63f471da99 Mon Sep 17 00:00:00 2001 From: Yinzuo Jiang Date: Wed, 19 Jun 2024 21:23:21 +0800 Subject: vim-patch:partial:9.1.0497: termdebug can be further improved Problem: termdebug can be further improved Solution: refactor save/restore, update docs, add a new save/restore test (Ubaldo Tiberi) closes: vim/vim#15032 https://github.com/vim/vim/commit/a48637c105ce5ccf6f3296958c889d15dc3faaa4 Co-authored-by: Ubaldo Tiberi --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 9d5d3f5b96..bc19c16941 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -168,7 +168,7 @@ func s:StartDebug_internal(dict) let b:save_signcolumn = &signcolumn let s:signcolumn_buflist = [bufnr()] - let s:save_columns = 0 + let s:saved_columns = 0 let s:allleft = v:false let wide = 0 if exists('g:termdebug_config') @@ -178,7 +178,7 @@ func s:StartDebug_internal(dict) endif if wide > 0 if &columns < wide - let s:save_columns = &columns + let s:saved_columns = &columns let &columns = wide " If we make the Vim window wider, use the whole left half for the debug " windows. @@ -808,8 +808,8 @@ func s:EndDebugCommon() call win_gotoid(curwinid) - if s:save_columns > 0 - let &columns = s:save_columns + if s:saved_columns > 0 + let &columns = s:saved_columns endif if exists('#User#TermdebugStopPost') @@ -1028,8 +1028,8 @@ func s:InstallCommands() let map = g:termdebug_map_K endif if map - let s:k_map_saved = maparg('K', 'n', 0, 1) - if !empty(s:k_map_saved) && !s:k_map_saved.buffer || empty(s:k_map_saved) + let s:saved_K_map = maparg('K', 'n', 0, 1) + if !empty(s:saved_K_map) && !s:saved_K_map.buffer || empty(s:saved_K_map) nnoremap K :Evaluate endif endif @@ -1039,8 +1039,8 @@ func s:InstallCommands() let map = get(g:termdebug_config, 'map_plus', 1) endif if map - let s:plus_map_saved = maparg('+', 'n', 0, 1) - if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer || empty(s:plus_map_saved) + let s:saved_plus_map = maparg('+', 'n', 0, 1) + if !empty(s:saved_plus_map) && !s:saved_plus_map.buffer || empty(s:saved_plus_map) nnoremap + $'{v:count1}Up' endif endif @@ -1050,8 +1050,8 @@ func s:InstallCommands() let map = get(g:termdebug_config, 'map_minus', 1) endif if map - let s:minus_map_saved = maparg('-', 'n', 0, 1) - if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer || empty(s:minus_map_saved) + let s:saved_minus_map = maparg('-', 'n', 0, 1) + if !empty(s:saved_minus_map) && !s:saved_minus_map.buffer || empty(s:saved_minus_map) nnoremap - $'{v:count1}Down' endif endif @@ -1119,32 +1119,32 @@ func s:DeleteCommands() delcommand Var delcommand Winbar - if exists('s:k_map_saved') - if !empty(s:k_map_saved) && !s:k_map_saved.buffer + if exists('s:saved_K_map') + if !empty(s:saved_K_map) && !s:saved_K_map.buffer nunmap K - call mapset(s:k_map_saved) - elseif empty(s:k_map_saved) + call mapset(s:saved_K_map) + elseif empty(s:saved_K_map) nunmap K endif - unlet s:k_map_saved + unlet s:saved_K_map endif - if exists('s:plus_map_saved') - if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer + if exists('s:saved_plus_map') + if !empty(s:saved_plus_map) && !s:saved_plus_map.buffer nunmap + - call mapset(s:plus_map_saved) - elseif empty(s:plus_map_saved) + call mapset(s:saved_plus_map) + elseif empty(s:saved_plus_map) nunmap + endif - unlet s:plus_map_saved + unlet s:saved_plus_map endif - if exists('s:minus_map_saved') - if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer + if exists('s:saved_minus_map') + if !empty(s:saved_minus_map) && !s:saved_minus_map.buffer nunmap - - call mapset(s:minus_map_saved) - elseif empty(s:minus_map_saved) + call mapset(s:saved_minus_map) + elseif empty(s:saved_minus_map) nunmap - endif - unlet s:minus_map_saved + unlet s:saved_minus_map endif if has('menu') -- cgit From 38a1d41ac08d1fe5688cdcac1e1e181f0cd82a5f Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 19 Jun 2024 20:04:09 +0200 Subject: vim-patch:aeca717: runtime(nohlsearch): simplify mapping Use instead of with execute(...)[-1] closes: vim/vim#15047 https://github.com/vim/vim/commit/aeca7176f3b7bdc2d698938062f6cad802fea783 Co-authored-by: Maxim Kim --- runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim index 6cfe813cfa..8d9930742c 100644 --- a/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim +++ b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim @@ -1,5 +1,5 @@ " nohlsearch.vim: Auto turn off hlsearch -" Last Change: 2024-06-18 +" Last Change: 2024-06-19 " Maintainer: Maxim Kim " " turn off hlsearch after: @@ -8,7 +8,7 @@ augroup nohlsearch au! noremap (nohlsearch) nohlsearch - noremap! (nohlsearch) execute('nohlsearch')[-1] + noremap! (nohlsearch) nohlsearch au CursorHold * call feedkeys("\(nohlsearch)", 'm') au InsertEnter * call feedkeys("\(nohlsearch)", 'm') augroup END -- cgit From c909efb96f30a9298df29f70bb3b839f6d568706 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 18 Jul 2024 09:55:48 +0800 Subject: vim-patch:83d0028: runtime(termdebug): Use string interpolation instead of string concat closes: vim/vim#14972 https://github.com/vim/vim/commit/83d0028026441d4e521d8849a5a0ef766e816cf2 Co-authored-by: Yegappan Lakshmanan --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 168 ++++++++++----------- 1 file changed, 82 insertions(+), 86 deletions(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index bc19c16941..51f9a3dca4 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -45,7 +45,7 @@ " - balloon -> vim.lsp.util.open_floating_preview func s:Echoerr(msg) - echohl ErrorMsg | echom '[termdebug] ' .. a:msg | echohl None + echohl ErrorMsg | echom $'[termdebug] {a:msg}' | echohl None endfunc " In case this gets sourced twice. @@ -91,9 +91,9 @@ endfunction func s:Highlight(init, old, new) let default = a:init ? 'default ' : '' 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' - exe "hi " . default . "debugPC term=reverse ctermbg=darkblue guibg=darkblue" + exe $"hi {default}debugPC term=reverse ctermbg=darkblue guibg=darkblue" endif endfunc @@ -143,7 +143,7 @@ func s:StartDebug_internal(dict) endif let gdbcmd = s:GetCommand() if !executable(gdbcmd[0]) - call s:Echoerr('Cannot execute debugger program "' .. gdbcmd[0] .. '"') + call s:Echoerr($'Cannot execute debugger program "{gdbcmd[0]}"') return endif @@ -227,12 +227,12 @@ endfunc " Use when debugger didn't start or ended. func s:CloseBuffers() - exe 'bwipe! ' . s:ptybufnr + exe $'bwipe! {s:ptybufnr}' if s:asmbufnr > 0 && bufexists(s:asmbufnr) - exe 'bwipe! ' . s:asmbufnr + exe $'bwipe! {s:asmbufnr}' endif if s:varbufnr > 0 && bufexists(s:varbufnr) - exe 'bwipe! ' . s:varbufnr + exe $'bwipe! {s:varbufnr}' endif let s:running = v:false unlet! s:gdbwin @@ -240,7 +240,8 @@ endfunc func s:IsGdbStarted() 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() return v:false endif @@ -265,7 +266,7 @@ func s:StartDebug_term(dict) if s:vertical " 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 s:allleft " use the whole left column wincmd H @@ -284,7 +285,7 @@ func s:StartDebug_term(dict) return elseif s:comm_job_id == -1 call s:Echoerr('Failed to open the communication terminal window') - exe 'bwipe! ' . s:ptybufnr + exe $'bwipe! {s:ptybufnr}' return endif 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 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')}) if s:gdb_job_id == 0 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. 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 " Connect gdb to the communication pty, using the GDB/MI interface. " 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 " why the debugger doesn't work. @@ -445,7 +446,7 @@ func s:StartDebug_prompt(dict) if s:vertical " 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 let gdb_args = get(a:dict, 'gdb_args', []) @@ -466,14 +467,14 @@ func s:StartDebug_prompt(dict) " Adding arguments requested by the user 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, { \ 'on_exit': function('s:EndPromptDebug'), \ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:GdbOutCallback')}), \ }) if s:gdbjob == 0 call s:Echoerr('Invalid argument (or job table is full) while starting gdb job') - exe 'bwipe! ' . s:ptybufnr + exe $'bwipe! {s:ptybufnr}' return elseif s:gdbjob == -1 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 pty = pty_job_info['pty'] 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 " match a terminal window, need to do that now. call s:SendCommand('set env TERM = xterm-color') - call s:SendCommand('set env ROWS = ' . 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 COLORS = ' . &t_Co) - call s:SendCommand('set env VIM_TERMINAL = ' . v:version) + call s:SendCommand($'set env ROWS = {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 COLORS = {&t_Co}') + call s:SendCommand($'set env VIM_TERMINAL = {v:version}') endif call s:SendCommand('set print pretty on') call s:SendCommand('set breakpoint pending on') " Set arguments to be run if len(proc_args) - call s:SendCommand('set args ' . join(proc_args)) + call s:SendCommand($'set args {join(proc_args)}') endif call s:StartDebugCommon(a:dict) @@ -564,18 +565,18 @@ endfunc " Send a command to gdb. "cmd" is the string without line terminator. func s:SendCommand(cmd) - "call ch_log('sending to gdb: ' . a:cmd) + " call ch_log($'sending to gdb: {a:cmd}') if s:way == 'prompt' - call chansend(s:gdbjob, a:cmd . "\n") + call chansend(s:gdbjob, $"{a:cmd}\n") else - call chansend(s:comm_job_id, a:cmd . "\r") + call chansend(s:comm_job_id, $"{a:cmd}\r") endif endfunc " This is global so that a user can create their mappings with this. func TermDebugSendCommand(cmd) if s:way == 'prompt' - call chansend(s:gdbjob, a:cmd . "\n") + call chansend(s:gdbjob, $"{a:cmd}\n") else let do_continue = 0 if !s:stopped @@ -590,7 +591,7 @@ func TermDebugSendCommand(cmd) sleep 10m endif " 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 Continue endif @@ -607,7 +608,7 @@ func s:SendResumingCommand(cmd) " call ch_log('assume that program is running after this command') call s:SendCommand(a:cmd) " else - " call ch_log('dropping command, program is running: ' . a:cmd) + " call ch_log($'dropping command, program is running: {a:cmd}') endif endfunc @@ -652,7 +653,7 @@ endfunc " Function called when gdb outputs text. 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 lines = [] @@ -711,7 +712,7 @@ endfunc " - change \\ to \ func s:DecodeMessage(quotedText, literal) if a:quotedText[0] != '"' - call s:Echoerr('DecodeMessage(): missing quote in ' . a:quotedText) + call s:Echoerr($'DecodeMessage(): missing quote in {a:quotedText}') return endif let msg = a:quotedText @@ -778,13 +779,13 @@ func s:EndDebugCommon() let curwinid = win_getid() if exists('s:ptybufnr') && s:ptybufnr - exe 'bwipe! ' . s:ptybufnr + exe $'bwipe! {s:ptybufnr}' endif if s:asmbufnr > 0 && bufexists(s:asmbufnr) - exe 'bwipe! ' . s:asmbufnr + exe $'bwipe! {s:asmbufnr}' endif if s:varbufnr > 0 && bufexists(s:varbufnr) - exe 'bwipe! ' . s:varbufnr + exe $'bwipe! {s:varbufnr}' endif let s:running = v:false @@ -793,7 +794,7 @@ func s:EndDebugCommon() let was_buf = bufnr() for bufnr in s:signcolumn_buflist if bufexists(bufnr) - exe bufnr .. "buf" + exe $":{bufnr}buf" if exists('b:save_signcolumn') let &signcolumn = b:save_signcolumn unlet b:save_signcolumn @@ -801,7 +802,7 @@ func s:EndDebugCommon() endif endfor if bufexists(was_buf) - exe was_buf .. "buf" + exe $":{was_buf}buf" endif call s:DeleteCommands() @@ -825,7 +826,7 @@ func s:EndPromptDebug(job_id, exit_code, event) endif if bufexists(s:promptbuf) - exe 'bwipe! ' . s:promptbuf + exe $'bwipe! {s:promptbuf}' endif call s:EndDebugCommon() @@ -854,7 +855,7 @@ func s:HandleDisasmMsg(msg) set nomodified set filetype=asm - let lnum = search('^' . s:asm_addr) + let lnum = search($'^{s:asm_addr}') if lnum != 0 call sign_unplace('TermDebug', #{id: s:asm_id}) call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum}) @@ -916,11 +917,8 @@ func s:HandleVariablesMsg(msg) silent! %delete _ let spaceBuffer = 20 - call setline(1, 'Type' . - \ repeat(' ', 16) . - \ 'Name' . - \ repeat(' ', 16) . - \ 'Value') + let spaces = repeat(' ', 16) + call setline(1, $'Type{spaces}Name{spaces}Value') let cnt = 1 let capture = '{name=".\{-}",\%(arg=".\{-}",\)\{0,1\}type=".\{-}"\%(,value=".\{-}"\)\{0,1\}}' let varinfo = matchstr(a:msg, capture, 0, cnt) @@ -1190,9 +1188,8 @@ func s:Until(at) let s:stopped = v:false " call ch_log('assume that program is running after this command') " Use the fname:lnum format - let at = empty(a:at) ? - \ fnameescape(expand('%:p')) . ':' . line('.') : a:at - call s:SendCommand('-exec-until ' . at) + let at = empty(a:at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : a:at + call s:SendCommand($'-exec-until {at}') " else " call ch_log('dropping command, program is running: exec-until') endif @@ -1210,12 +1207,11 @@ func s:SetBreakpoint(at, tbreak=v:false) endif " Use the fname:lnum format, older gdb can't handle --source. - let at = empty(a:at) ? - \ fnameescape(expand('%:p')) . ':' . line('.') : a:at + let at = empty(a:at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : a:at if a:tbreak - let cmd = '-break-insert -t ' . at + let cmd = $'-break-insert -t {at}' else - let cmd = '-break-insert ' . at + let cmd = $'-break-insert {at}' endif call s:SendCommand(cmd) if do_continue @@ -1234,7 +1230,7 @@ func s:ClearBreakpoint() 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) + call s:SendCommand($'-break-delete {id}') for subid in keys(s:breakpoints[id]) call sign_unplace('TermDebug', \ #{id: s:Breakpoint2SignNumber(id, subid)}) @@ -1251,18 +1247,18 @@ func s:ClearBreakpoint() if empty(s:breakpoint_locations[bploc]) unlet s:breakpoint_locations[bploc] endif - echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.' + echomsg $'Breakpoint {nr} cleared from line {lnum}.' 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 else - echomsg 'No breakpoint to remove at line ' . lnum . '.' + echomsg $'No breakpoint to remove at line {lnum}.' endif endfunc func s:Run(args) if a:args != '' - call s:SendResumingCommand('-exec-arguments ' . a:args) + call s:SendResumingCommand($'-exec-arguments {a:args}') endif call s:SendResumingCommand('-exec-run') endfunc @@ -1276,13 +1272,13 @@ func s:Frame(arg) " already parsed and allows for more formats if a:arg =~ '^\d\+$' || a:arg == '' " 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]\+$' " 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 " 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 endfunc @@ -1308,10 +1304,10 @@ func s:SendEval(expr) endif " encoding expression to prevent bad errors - let expr = a:expr - let expr = substitute(expr, '\\', '\\\\', 'g') - let expr = substitute(expr, '"', '\\"', 'g') - call s:SendCommand('-data-evaluate-expression "' . expr . '"') + let expr_escaped = a:expr + \ ->substitute('\\', '\\\\', 'g') + \ ->substitute('"', '\\"', 'g') + call s:SendCommand($'-data-evaluate-expression "{expr_escaped}"') let s:evalexpr = exprLHS endfunc @@ -1401,9 +1397,9 @@ func s:HandleEvaluate(msg) \ ->substitute(' ', '\1', '') if s:evalFromBalloonExpr if s:evalFromBalloonExprResult == '' - let s:evalFromBalloonExprResult = s:evalexpr . ': ' . value + let s:evalFromBalloonExprResult = $'{s:evalexpr}: {value}' else - let s:evalFromBalloonExprResult .= ' = ' . value + let s:evalFromBalloonExprResult ..= $' = {value}' endif " NEOVIM: " - Result pretty-printing is not implemented. Vim prettifies the result @@ -1415,13 +1411,13 @@ func s:HandleEvaluate(msg) " first message. let s:eval_float_win_id = luaeval('select(2, vim.lsp.util.open_floating_preview(_A))', [s:evalFromBalloonExprResult]) else - echomsg '"' . s:evalexpr . '": ' . value + echomsg $'"{s:evalexpr}": {value}' endif if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$' " Looks like a pointer, also display what it points to. let s:ignoreEvalError = v:true - call s:SendEval('*' . s:evalexpr) + call s:SendEval($'*{s:evalexpr}') endif endfunc @@ -1472,7 +1468,7 @@ func s:GotoAsmwinOrCreateIt() " 60 is approx spaceBuffer * 3 if winwidth(0) > (78 + 60) let mdf = 'vert' - exe mdf .. ' ' .. 60 .. 'new' + exe $'{mdf} :60new' else exe 'rightbelow new' endif @@ -1491,7 +1487,7 @@ func s:GotoAsmwinOrCreateIt() setlocal modifiable if s:asmbufnr > 0 && bufexists(s:asmbufnr) - exe 'buffer' . s:asmbufnr + exe $'buffer {s:asmbufnr}' elseif empty(glob('Termdebug-asm-listing')) silent file Termdebug-asm-listing let s:asmbufnr = bufnr('Termdebug-asm-listing') @@ -1501,12 +1497,12 @@ func s:GotoAsmwinOrCreateIt() endif if mdf != 'vert' && s:GetDisasmWindowHeight() > 0 - exe 'resize ' .. s:GetDisasmWindowHeight() + exe $'resize {s:GetDisasmWindowHeight()}' endif endif if s:asm_addr != '' - let lnum = search('^' . s:asm_addr) + let lnum = search($'^{s:asm_addr}') if lnum == 0 if s:stopped call s:SendCommand('disassemble $pc') @@ -1545,7 +1541,7 @@ func s:GotoVariableswinOrCreateIt() " 60 is approx spaceBuffer * 3 if winwidth(0) > (78 + 60) let mdf = 'vert' - exe mdf .. ' ' .. 60 .. 'new' + exe $'{mdf} :60new' else exe 'rightbelow new' endif @@ -1563,7 +1559,7 @@ func s:GotoVariableswinOrCreateIt() setlocal modifiable if s:varbufnr > 0 && bufexists(s:varbufnr) - exe 'buffer' . s:varbufnr + exe $'buffer {s:varbufnr}' elseif empty(glob('Termdebug-variables-listing')) silent file Termdebug-variables-listing let s:varbufnr = bufnr('Termdebug-variables-listing') @@ -1573,7 +1569,7 @@ func s:GotoVariableswinOrCreateIt() endif if mdf != 'vert' && s:GetVariablesWindowHeight() > 0 - exe 'resize ' .. s:GetVariablesWindowHeight() + exe $'resize {s:GetVariablesWindowHeight()}' endif endif @@ -1612,7 +1608,7 @@ func s:HandleCursor(msg) let curwinid = win_getid() if win_gotoid(s:asmwin) - let lnum = search('^' . s:asm_addr) + let lnum = search($'^{s:asm_addr}') if lnum == 0 call s:SendCommand('disassemble $pc') else @@ -1634,7 +1630,7 @@ func s:HandleCursor(msg) if lnum =~ '^[0-9]*$' call s: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. @@ -1646,17 +1642,17 @@ func s:HandleCursor(msg) augroup END if &modified " TODO: find existing window - exe 'split ' . fnameescape(fname) + exe $'split {fnameescape(fname)}' let s:sourcewin = win_getid() call s: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 call sign_unplace('TermDebug', #{id: s:pc_id}) call sign_place(s:pc_id, 'TermDebug', 'debugPC', fname, @@ -1695,7 +1691,7 @@ func s:CreateBreakpoint(id, subid, enabled) let label = 'F+' endif endif - call sign_define('debugBreakpoint' .. nr, + call sign_define($'debugBreakpoint{nr}', \ #{text: slice(label, 0, 2), \ texthl: hiName}) endif @@ -1713,7 +1709,7 @@ func s:HandleNewBreakpoint(msg, modifiedFlag) if a:msg =~ 'pending=' let nr = substitute(a:msg, '.*number=\"\([0-9.]*\)\".*', '\1', '') let target = substitute(a:msg, '.*pending=\"\([^"]*\)\".*', '\1', '') - echomsg 'Breakpoint ' . nr . ' (' . target . ') pending.' + echomsg $'Breakpoint {nr} ({target}) pending.' endif return endif @@ -1758,9 +1754,9 @@ func s:HandleNewBreakpoint(msg, modifiedFlag) if bufloaded(fname) call s:PlaceSign(id, subid, entry) - let posMsg = ' at line ' . lnum . '.' + let posMsg = $' at line {lnum}.' else - let posMsg = ' in ' . fname . ' at line ' . lnum . '.' + let posMsg = $' in {fname} at line {lnum}.' endif if !a:modifiedFlag let actionTaken = 'created' @@ -1769,14 +1765,14 @@ func s:HandleNewBreakpoint(msg, modifiedFlag) else let actionTaken = 'enabled' endif - echomsg 'Breakpoint ' . nr . ' ' . actionTaken . posMsg + echom $'Breakpoint {nr} {actionTaken}{posMsg}' endfor endfunc func s:PlaceSign(id, subid, entry) let nr = printf('%d.%d', a:id, a:subid) 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}) let a:entry['placed'] = 1 endfunc @@ -1797,7 +1793,7 @@ func s:HandleBreakpointDelete(msg) endif endfor unlet s:breakpoints[id] - echomsg 'Breakpoint ' . id . ' cleared.' + echomsg $'Breakpoint {id} cleared.' endif endfunc @@ -1809,7 +1805,7 @@ func s:HandleProgramRun(msg) return endif let s:pid = nr - "call ch_log('Detected process ID: ' . s:pid) + " call ch_log($'Detected process ID: {s:pid}') endfunc " Handle a BufRead autocommand event: place any signs. -- cgit From 8ce85d5fc706ff523950f17d7464eb7dd2842633 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 18 Jul 2024 13:16:50 +0800 Subject: vim-patch:c3837a4: runtime(termdebug): fix a few issues Fix a few minor issues: 1. filename with whitespaces issue should be fixed now, fixes: vim/vim#12357 2. ":Termdebug args" should work now, fixes: vim/vim#15254 closes: vim/vim#15261 https://github.com/vim/vim/commit/c3837a46ff5f31e9b18f8f86b6e464bed1fe20d1 Omit the DeleteCommands() change as it isn't really an improvement. Co-authored-by: Ubaldo Tiberi --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 51f9a3dca4..cf14f66c4b 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -361,7 +361,7 @@ func s:StartDebug_term(dict) endwhile " Set arguments to be run. - if len(proc_args) + if !empty(proc_args) call chansend(s:gdb_job_id, $"server set args {join(proc_args)}\r") endif @@ -1188,7 +1188,7 @@ func s:Until(at) let s:stopped = v:false " call ch_log('assume that program is running after this command') " Use the fname:lnum format - let at = empty(a:at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : a:at + let at = empty(a:at) ? $"\"{expand('%:p')}:{line('.')}\"" : a:at call s:SendCommand($'-exec-until {at}') " else " call ch_log('dropping command, program is running: exec-until') @@ -1207,7 +1207,7 @@ func s:SetBreakpoint(at, tbreak=v:false) endif " Use the fname:lnum format, older gdb can't handle --source. - let at = empty(a:at) ? $"{fnameescape(expand('%:p'))}:{line('.')}" : a:at + let at = empty(a:at) ? $"\"{expand('%:p')}:{line('.')}\"" : a:at if a:tbreak let cmd = $'-break-insert -t {at}' else -- cgit From be7b5774531364e6f1e2b2cec3c297a3bb84a60d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 18 Jul 2024 13:26:16 +0800 Subject: vim-patch:27f5334: runtime(termdebug): quote filename arguments using double quotes closes: vim/vim#15270 https://github.com/vim/vim/commit/27f53346a303c5cf1bdfb8abca20e4fea8ec05e4 Co-authored-by: Ubaldo Tiberi --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index cf14f66c4b..6227a20e3c 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1181,6 +1181,12 @@ func s:DeleteCommands() let s:BreakpointSigns = [] endfunc +func s:QuoteArg(x) + " Find all the occurrences of " and \ and escape them and double quote + " the resulting string. + return printf('"%s"', a:x->substitute('[\\"]', '\\&', 'g')) +endfunc + " :Until - Execute until past a specified position or current line func s:Until(at) if s:stopped @@ -1188,7 +1194,7 @@ func s:Until(at) let s:stopped = v:false " call ch_log('assume that program is running after this command') " Use the fname:lnum format - let at = empty(a:at) ? $"\"{expand('%:p')}:{line('.')}\"" : a:at + let at = empty(a:at) ? s:QuoteArg($"{expand('%:p')}:{line('.')}") : a:at call s:SendCommand($'-exec-until {at}') " else " call ch_log('dropping command, program is running: exec-until') @@ -1207,7 +1213,7 @@ func s:SetBreakpoint(at, tbreak=v:false) endif " Use the fname:lnum format, older gdb can't handle --source. - let at = empty(a:at) ? $"\"{expand('%:p')}:{line('.')}\"" : a:at + let at = empty(a:at) ? s:QuoteArg($"{expand('%:p')}:{line('.')}") : a:at if a:tbreak let cmd = $'-break-insert -t {at}' else -- cgit From 0b710c8e55930a082e030f980f84bd1e71a29592 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Jul 2024 11:48:13 +0800 Subject: vim-patch:9.1.0599: Termdebug: still get E1023 when specifying arguments (#29794) Problem: Termdebug: still get E1023 when specifying arguments and using a prompt buffer. Solution: Use empty() instead of len(). Add a test. Fix wrong order of arguments to assert_equal() in Test_termdebug_basic(). (zeertzjq) closes: vim/vim#15288 https://github.com/vim/vim/commit/aef6179bcf04918002103528651996c754c03840 --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 6227a20e3c..9412a821e8 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -518,7 +518,7 @@ func s:StartDebug_prompt(dict) call s:SendCommand('set breakpoint pending on') " Set arguments to be run - if len(proc_args) + if !empty(proc_args) call s:SendCommand($'set args {join(proc_args)}') endif -- cgit From e1d48d5cf295293598144c351ace5f1e07c0cb7c Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 31 Jul 2024 22:45:00 +0200 Subject: vim-patch:5753d99: runtime(nohlsearch): add missing loaded_hlsearch guard related: vim/vim#15039 closes: vim/vim#15402 https://github.com/vim/vim/commit/5753d99ff667d0feeff6b582bb7df9aaedd9a2cb Co-authored-by: Maxim Kim --- runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'runtime/pack/dist') diff --git a/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim index 8d9930742c..a2d766e41a 100644 --- a/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim +++ b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim @@ -1,10 +1,16 @@ " nohlsearch.vim: Auto turn off hlsearch -" Last Change: 2024-06-19 +" Last Change: 2024-07-31 " Maintainer: Maxim Kim " " turn off hlsearch after: " - doing nothing for 'updatetime' " - getting into insert mode + +if exists('g:loaded_nohlsearch') + finish +endif +let g:loaded_nohlsearch = 1 + augroup nohlsearch au! noremap (nohlsearch) nohlsearch -- cgit