vim-patch:fce324f557: runtime(termdebug): close all buffers in the same way

For ASM and Variables buffer, check were done to make sure they existed
before attempting to close them, but not for debugged program or gdb
communication. The debugged program window is a user-facing one and
user might close it manually, so it's better to check if it exists.

fce324f557

Co-authored-by: Damien Riegel <damien@riegel.io>
AI-assisted: Codex
This commit is contained in:
Yinzuo Jiang
2026-03-14 12:48:23 +08:00
committed by zeertzjq
parent 3cd07709ba
commit 34fea4fc64

View File

@@ -227,12 +227,16 @@ endfunc
" Use when debugger didn't start or ended.
func s:CloseBuffers()
exe $'bwipe! {s:ptybufnr}'
if s:asmbufnr > 0 && bufexists(s:asmbufnr)
exe $'bwipe! {s:asmbufnr}'
endif
if s:varbufnr > 0 && bufexists(s:varbufnr)
exe $'bwipe! {s:varbufnr}'
for bufnr in [get(s:, 'ptybufnr', 0), get(s:, 'asmbufnr', 0), get(s:, 'varbufnr', 0)]
if bufnr > 0 && bufexists(bufnr)
execute $'bwipe! {bufnr}'
endif
endfor
if exists('s:comm_job_id')
let commbufnr = get(nvim_get_chan_info(s:comm_job_id), 'buffer', 0)
if commbufnr > 0 && bufexists(commbufnr)
execute $'bwipe! {commbufnr}'
endif
endif
let s:running = v:false
unlet! s:gdbwin