To: vim_dev@googlegroups.com Subject: Patch 8.2.2397 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2397 Problem: Vim9: "%%" not seen as alternate file name for commands with a buffer name argument. Solution: Recognize "%%" like "#". (closes #7732) Files: src/buffer.c, src/testdir/test_vim9_cmd.vim *** ../vim-8.2.2396/src/buffer.c 2021-01-15 16:22:48.708565105 +0100 --- src/buffer.c 2021-01-23 15:14:22.928369185 +0100 *************** *** 2564,2575 **** char_u *p; int toggledollar; ! if (pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#')) { ! if (*pattern == '%') ! match = curbuf->b_fnum; ! else match = curwin->w_alt_fnum; #ifdef FEAT_DIFF if (diffmode && !diff_mode_buf(buflist_findnr(match))) match = -1; --- 2564,2578 ---- char_u *p; int toggledollar; ! // "%" is current file, "%%" or "#" is alternate file ! if ((pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#')) ! || (in_vim9script() && pattern_end == pattern + 2 ! && pattern[0] == '%' && pattern[1] == '%')) { ! if (*pattern == '#' || pattern_end == pattern + 2) match = curwin->w_alt_fnum; + else + match = curbuf->b_fnum; #ifdef FEAT_DIFF if (diffmode && !diff_mode_buf(buflist_findnr(match))) match = -1; *** ../vim-8.2.2396/src/testdir/test_vim9_cmd.vim 2021-01-23 14:22:10.228667110 +0100 --- src/testdir/test_vim9_cmd.vim 2021-01-23 15:11:45.144835546 +0100 *************** *** 68,73 **** --- 68,84 ---- edit Xfiletwo edit %%:r assert_equal('Xfileone', bufname()) + + assert_false(bufexists('altfoo')) + edit altfoo + edit bar + assert_true(bufexists('altfoo')) + assert_true(buflisted('altfoo')) + bdel %% + assert_true(bufexists('altfoo')) + assert_false(buflisted('altfoo')) + bwipe! altfoo + bwipe! bar END CheckDefAndScriptSuccess(lines) enddef *** ../vim-8.2.2396/src/version.c 2021-01-23 14:22:10.232667100 +0100 --- src/version.c 2021-01-23 15:01:31.434626883 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2397, /**/ -- From the classified section of a city newspaper: Dog for sale: eats anything and is fond of children. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///