]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(termdebug): close all buffers in the same way
authorDamien Riegel <damien@riegel.io>
Fri, 14 Jun 2024 16:15:11 +0000 (12:15 -0400)
committerChristian Brabandt <cb@256bit.org>
Fri, 14 Jun 2024 18:41:36 +0000 (20:41 +0200)
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.

Signed-off-by: Damien Riegel <damien@riegel.io>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim

index 15d03971986e41bb5e975b07946aa56ccbf58766..a1c92ba0b705f13c1cd4e36a565f98479a848595 100644 (file)
@@ -328,14 +328,14 @@ enddef
 
 # Use when debugger didn't start or ended.
 def CloseBuffers()
-  exe $'bwipe! {ptybufnr}'
-  exe $'bwipe! {commbufnr}'
-  if asmbufnr > 0 && bufexists(asmbufnr)
-    exe $'bwipe! {asmbufnr}'
-  endif
-  if varbufnr > 0 && bufexists(varbufnr)
-    exe $'bwipe! {varbufnr}'
-  endif
+  var bufnames = ['debugged\ program', 'gdb\ communication', asmbufname, varbufname]
+  for bufname in bufnames
+    var buf_nr = bufnr(bufname)
+    if buf_nr > 0 && bufexists(buf_nr)
+      exe $'bwipe! {bufname}'
+    endif
+  endfor
+
   running = 0
   gdbwin = 0
 enddef