vim-patch:8.2.1902: default option values changed with :badd for existing buffer

Problem:    Default option values are changed when using :badd for an existing
            buffer.
Solution:   When calling buflist_new() pass a zero line number. (closes vim/vim#7195)
e974fa7b2b
This commit is contained in:
Jan Edmund Lazo
2021-02-13 13:34:43 -05:00
parent 5ad32885d4
commit 9860d14af3
2 changed files with 15 additions and 1 deletions

View File

@@ -2324,7 +2324,9 @@ int do_ecmd(
buf = buflist_findnr(fnum); buf = buflist_findnr(fnum);
} else { } else {
if (flags & (ECMD_ADDBUF | ECMD_ALTBUF)) { if (flags & (ECMD_ADDBUF | ECMD_ALTBUF)) {
linenr_T tlnum = 1L; // Default the line number to zero to avoid that a wininfo item
// is added for the current window.
linenr_T tlnum = 0;
if (command != NULL) { if (command != NULL) {
tlnum = atol((char *)command); tlnum = atol((char *)command);

View File

@@ -1,5 +1,17 @@
" Tests for Vim buffer " Tests for Vim buffer
func Test_badd_options()
new SomeNewBuffer
setlocal cole=3
wincmd p
badd SomeNewBuffer
new SomeNewBuffer
call assert_equal(3, &cole)
close
close
bwipe! SomeNewBuffer
endfunc
func Test_balt() func Test_balt()
new SomeNewBuffer new SomeNewBuffer
balt +3 OtherBuffer balt +3 OtherBuffer