소스 검색

Retain buffer until it has been fully wiped.

When deleting a buffer with `:bd`, the buffer becomes unlisted.  This
means the buffer should remain in the raw buffer list (though with
updated attributes), and if unlisted buffers are being displayed, the
buffer should stay visible.  It's also possible that wiping a buffer
might fail for some reason, in which case the buffer should be retained
in the buffer list.

After attempting to remove a buffer (either via `:bd` or `:bw`), if the
buffer still exists, regather information on that buffer and update the
display accordingly.
Michael Henry 9 달 전
부모
커밋
e7146c7545
1개의 변경된 파일13개의 추가작업 그리고 3개의 파일을 삭제
  1. 13 3
      plugin/bufexplorer.vim

+ 13 - 3
plugin/bufexplorer.vim

@@ -1256,7 +1256,19 @@ function! s:DeleteBuffer(bufNbr, mode)
         else
             execute "silent bdelete" a:bufNbr
         endif
+    catch
+        call s:Error(v:exception)
+    endtry
 
+    if bufexists(a:bufNbr)
+        " Buffer is still present.  We may have failed to wipe it, or it may
+        " have changed attributes (as `:bd` only makes a buffer unlisted).
+        " Regather information on this buffer, update the buffer list, and
+        " redisplay.
+        let info = s:GetBufferInfo(a:bufNbr)
+        let s:raw_buffer_listing[a:bufNbr] = info[a:bufNbr]
+        call s:RedisplayBufferList()
+    else
         " Delete the buffer from the list on screen.
         setlocal modifiable
         normal! "_dd
@@ -1264,9 +1276,7 @@ function! s:DeleteBuffer(bufNbr, mode)
 
         " Delete the buffer from the raw buffer list.
         unlet s:raw_buffer_listing[a:bufNbr]
-    catch
-        call s:Error(v:exception)
-    endtry
+    endif
 endfunction
 
 " Close {{{2