diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2022-03-20 10:10:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-20 10:10:01 +0000 |
commit | 315858bf67599d39c38628cd2ab8bff1074d7fe4 (patch) | |
tree | fde0fb6c731d647eb6af38e7b47bbf5dfec0e0c6 | |
parent | 75157d2572248c330858586fa23649e7acf33416 (diff) | |
download | rneovim-315858bf67599d39c38628cd2ab8bff1074d7fe4.tar.gz rneovim-315858bf67599d39c38628cd2ab8bff1074d7fe4.tar.bz2 rneovim-315858bf67599d39c38628cd2ab8bff1074d7fe4.zip |
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.
-rw-r--r-- | runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 63aba72f0d..71456e788d 100644 --- 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 |