mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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)
This commit is contained in:
11
src/buffer.c
11
src/buffer.c
@@ -2564,12 +2564,15 @@ buflist_findpat(
|
|||||||
char_u *p;
|
char_u *p;
|
||||||
int toggledollar;
|
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 = curbuf->b_fnum;
|
|
||||||
else
|
|
||||||
match = curwin->w_alt_fnum;
|
match = curwin->w_alt_fnum;
|
||||||
|
else
|
||||||
|
match = curbuf->b_fnum;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (diffmode && !diff_mode_buf(buflist_findnr(match)))
|
if (diffmode && !diff_mode_buf(buflist_findnr(match)))
|
||||||
match = -1;
|
match = -1;
|
||||||
|
@@ -68,6 +68,17 @@ def Test_expand_alternate_file()
|
|||||||
edit Xfiletwo
|
edit Xfiletwo
|
||||||
edit %%:r
|
edit %%:r
|
||||||
assert_equal('Xfileone', bufname())
|
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
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2397,
|
||||||
/**/
|
/**/
|
||||||
2396,
|
2396,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user