patch 9.1.0046: :drop does not re-use empty buffer
Problem: :drop does not re-use empty buffer
(Rocco Mao)
Solution: Make :drop re-use an empty buffer
(Rocco Mao)
fixes: #13851
closes: #13881
Signed-off-by: Rocco Mao <dapeng.mao@qq.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim
index 47fc267..6a7829b 100644
--- a/src/testdir/test_excmd.vim
+++ b/src/testdir/test_excmd.vim
@@ -84,18 +84,27 @@
" Test for the :drop command
func Test_drop_cmd()
call writefile(['L1', 'L2'], 'Xdropfile', 'D')
+ " Test for reusing the current buffer
enew | only
+ let expected_nr = bufnr()
drop Xdropfile
+ call assert_equal(expected_nr, bufnr())
call assert_equal('L2', getline(2))
" Test for switching to an existing window
below new
drop Xdropfile
call assert_equal(1, winnr())
- " Test for splitting the current window
+ " Test for splitting the current window (set nohidden)
enew | only
set modified
drop Xdropfile
call assert_equal(2, winnr('$'))
+ " Not splitting the current window even if modified (set hidden)
+ set hidden
+ enew | only
+ set modified
+ drop Xdropfile
+ call assert_equal(1, winnr('$'))
" Check for setting the argument list
call assert_equal(['Xdropfile'], argv())
enew | only!