0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 8.1.1611: bufadd() reuses existing buffer without a name

Problem:    Bufadd() reuses existing buffer without a name.
Solution:   When the name is empty always create a new buffer.
This commit is contained in:
Bram Moolenaar
2019-06-30 20:33:01 +02:00
parent 15e248e37f
commit 892ae723ab
3 changed files with 19 additions and 1 deletions

View File

@@ -1539,6 +1539,20 @@ func Test_bufadd_bufload()
call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
call assert_equal(curbuf, bufnr(''))
let buf1 = bufadd('')
let buf2 = bufadd('')
call assert_notequal(0, buf1)
call assert_notequal(0, buf2)
call assert_notequal(buf1, buf2)
call assert_equal(1, bufexists(buf1))
call assert_equal(1, bufexists(buf2))
call assert_equal(0, bufloaded(buf1))
exe 'bwipe ' .. buf1
call assert_equal(0, bufexists(buf1))
call assert_equal(1, bufexists(buf2))
exe 'bwipe ' .. buf2
call assert_equal(0, bufexists(buf2))
bwipe someName
bwipe otherName
call assert_equal(0, bufexists('someName'))