From a2b91036d12e1b406ed5d17bf03f8d1ed05221f6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 19 Sep 2022 18:20:08 +0100 Subject: [PATCH] patch 9.0.0506: line number argument for :badd does not work Problem: Line number argument for :badd does not work. Solution: Set the last cursor position in the new buffer. (closes #11161) --- src/ex_cmds.c | 9 +++++++-- src/testdir/test_buffer.vim | 7 +++++++ src/version.c | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 9fdbe955e..265927c4c 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2651,8 +2651,13 @@ do_ecmd( // with the current window. newbuf = buflist_new(ffname, sfname, tlnum, BLN_LISTED | BLN_NOCURWIN); - if (newbuf != NULL && (flags & ECMD_ALTBUF)) - curwin->w_alt_fnum = newbuf->b_fnum; + if (newbuf != NULL) + { + if (flags & ECMD_ALTBUF) + curwin->w_alt_fnum = newbuf->b_fnum; + if (tlnum > 0) + newbuf->b_last_cursor.lnum = tlnum; + } goto theend; } buf = buflist_new(ffname, sfname, 0L, diff --git a/src/testdir/test_buffer.vim b/src/testdir/test_buffer.vim index 9387b5f6c..bc29c2162 100644 --- a/src/testdir/test_buffer.vim +++ b/src/testdir/test_buffer.vim @@ -361,6 +361,13 @@ func Test_badd_options() close close bwipe! SomeNewBuffer + + badd +3 XbaddFile + call writefile(range(6), 'XbaddFile', 'D') + buf XbaddFile + call assert_equal([0, 3, 1, 0], getpos('.')) + + bwipe! XbaddFile endfunc func Test_balt() diff --git a/src/version.c b/src/version.c index 9de067617..15f5e3854 100644 --- a/src/version.c +++ b/src/version.c @@ -699,6 +699,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 506, /**/ 505, /**/ -- 2.40.0