vim-patch:9.0.0261: bufload() reads a file even if the name is not a file name (#19944)

Problem:    bufload() reads a file even if the name is not a file name. (Cyker
            Way)
Solution:   Do not read the file when the buffer name is not a file name.
            (closes vim/vim#10975)
2eddbacd6d
This commit is contained in:
zeertzjq
2022-08-25 20:23:29 +08:00
committed by GitHub
parent 1b29288709
commit cd2d3aa48f
3 changed files with 13 additions and 3 deletions

View File

@@ -224,7 +224,8 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
// mark cursor position as being invalid
curwin->w_valid = 0;
if (curbuf->b_ffname != NULL) {
// Read the file if there is one.
if (curbuf->b_ffname != NULL && !bt_quickfix(curbuf) && !bt_nofilename(curbuf)) {
#ifdef UNIX
int save_bin = curbuf->b_p_bin;
int perm;

View File

@@ -1880,6 +1880,13 @@ func Test_bufadd_bufload()
exe 'bwipe ' .. buf2
call assert_equal(0, bufexists(buf2))
" when 'buftype' is "nofile" then bufload() does not read the file
bwipe! XotherName
let buf = bufadd('XotherName')
call setbufvar(buf, '&bt', 'nofile')
call bufload(buf)
call assert_equal([''], getbufline(buf, 1, '$'))
bwipe someName
bwipe XotherName
call assert_equal(0, bufexists('someName'))