neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 315858bf67599d39c38628cd2ab8bff1074d7fe4
parent 75157d2572248c330858586fa23649e7acf33416
Author: Sean Dewar <seandewar@users.noreply.github.com>
Date:   Sun, 20 Mar 2022 10:10:01 +0000

fix(termdebug): handle exiting during startup properly (#16790)

s:EndTermDebug should only be called when exiting if the debugger started
without error, otherwise the plugin breaks.

Vim handles this by using job_setoptions to set the on_exit callback to
s:EndTermDebug after startup succeeds. However, Nvim does not have such
functionality; instead; use s:starting to mimic this behaviour.

Also, introduce s:running to fix s:CheckGdbRunning; it did not work correctly
due to the "[Process exited X]" message keeping the job's channel alive (though
the stream is closed). This means nvim_get_chan_info cannot be used to check if
the debugger has exited, as it may still return a non-empty dict.
Diffstat:
Mruntime/pack/dist/opt/termdebug/plugin/termdebug.vim | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -197,7 +197,7 @@ func s:CloseBuffers() endfunc func s:CheckGdbRunning() - if nvim_get_chan_info(s:gdb_job_id) == {} + if !s:running echoerr string(s:GetCommand()[0]) . ' exited unexpectedly' call s:CloseBuffers() return '' @@ -280,6 +280,8 @@ func s:StartDebug_term(dict) call s:CloseBuffers() return endif + let s: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:gdbwin = win_getid(winnr()) @@ -355,6 +357,8 @@ func s:StartDebug_term(dict) sleep 10m endwhile + let s:starting = v:false + " Set the filetype, this can be used to add mappings. set filetype=termdebug @@ -663,6 +667,11 @@ func s:GetAsmAddr(msg) endfunc function s:EndTermDebug(job_id, exit_code, event) + let s:running = v:false + if s:starting + return + endif + if exists('#User#TermdebugStopPre') doauto <nomodeline> User TermdebugStopPre endif