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;
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