Mercurial > vim
changeset 23711:29eccef07e2f v8.2.2397
patch 8.2.2397: Vim9: "%%" not seen as alternate file name for ":bdel"
Commit: https://github.com/vim/vim/commit/dfbc5fd879d92c2a79ced1e1d16dc89f4d55772d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 23 15:15:01 2021 +0100
patch 8.2.2397: Vim9: "%%" not seen as alternate file name for ":bdel"
Problem: Vim9: "%%" not seen as alternate file name for commands with a
buffer name argument.
Solution: Recognize "%%" like "#". (closes #7732)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 23 Jan 2021 15:30:04 +0100 |
parents | 5f90c249c3e9 |
children | f0763be692f4 |
files | src/buffer.c src/testdir/test_vim9_cmd.vim src/version.c |
diffstat | 3 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buffer.c +++ b/src/buffer.c @@ -2564,12 +2564,15 @@ buflist_findpat( char_u *p; int toggledollar; - if (pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#')) + // "%" 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 == '%') + if (*pattern == '#' || pattern_end == pattern + 2) + match = curwin->w_alt_fnum; + else match = curbuf->b_fnum; - else - match = curwin->w_alt_fnum; #ifdef FEAT_DIFF if (diffmode && !diff_mode_buf(buflist_findnr(match))) match = -1;
--- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -68,6 +68,17 @@ def Test_expand_alternate_file() 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