diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-23 15:15:01 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-23 15:15:01 +0100 |
commit | dfbc5fd879d92c2a79ced1e1d16dc89f4d55772d (patch) | |
tree | bec3b4a150b024d88522a76c864c7bc2007ed129 /src/buffer.c | |
parent | 7cebe8ba7dd9a3a955e2da74014f11c42e1c6ac3 (diff) |
patch 8.2.2397: Vim9: "%%" not seen as alternate file name for ":bdel"v8.2.2397
Problem: Vim9: "%%" not seen as alternate file name for commands with a
buffer name argument.
Solution: Recognize "%%" like "#". (closes #7732)
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/buffer.c b/src/buffer.c index c347ef9a64..f9bffbf3d8 100644 --- 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 == '%') - match = curbuf->b_fnum; - else + 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; |