]> granicus.if.org Git - vim/commitdiff
patch 9.0.0506: line number argument for :badd does not work v9.0.0506
authorBram Moolenaar <Bram@vim.org>
Mon, 19 Sep 2022 17:20:08 +0000 (18:20 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 19 Sep 2022 17:20:08 +0000 (18:20 +0100)
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
src/testdir/test_buffer.vim
src/version.c

index 9fdbe955e0f95b73c0c2f3865e7ec5b63875d180..265927c4cde75e7670aa0c6425bf580cebc314a3 100644 (file)
@@ -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,
index 9387b5f6c4c8316e3a13ab1fe5d2379cb0fb01ea..bc29c21621977d37a8e0264d87d46fb195ae50bd 100644 (file)
@@ -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()
index 9de06761770b1d8cd4d8f6d1030c9e65aa5eb740..15f5e385443a69a156039fc7ea8098406a945366 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    506,
 /**/
     505,
 /**/