forked from aniani/vim
patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Problem: expand("%:p") is not empty when there is no buffer name. Solution: When ignoring errors still return NULL. (closes #10311)
This commit is contained in:
@@ -9349,12 +9349,15 @@ eval_vars(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty_is_error && (resultlen == 0 || valid != VALID_HEAD + VALID_PATH))
|
if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)
|
||||||
{
|
{
|
||||||
if (valid != VALID_HEAD + VALID_PATH)
|
if (empty_is_error)
|
||||||
*errormsg = _(e_empty_file_name_for_percent_or_hash_only_works_with_ph);
|
{
|
||||||
else
|
if (valid != VALID_HEAD + VALID_PATH)
|
||||||
*errormsg = _(e_evaluates_to_an_empty_string);
|
*errormsg = _(e_empty_file_name_for_percent_or_hash_only_works_with_ph);
|
||||||
|
else
|
||||||
|
*errormsg = _(e_evaluates_to_an_empty_string);
|
||||||
|
}
|
||||||
result = NULL;
|
result = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -82,7 +82,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_expand()
|
func Test_expand()
|
||||||
new
|
new
|
||||||
call assert_equal("''", expand('%:S'))
|
call assert_equal("", expand('%:S'))
|
||||||
call assert_equal('3', '<slnum>'->expand())
|
call assert_equal('3', '<slnum>'->expand())
|
||||||
call assert_equal(['4'], expand('<slnum>', v:false, v:true))
|
call assert_equal(['4'], expand('<slnum>', v:false, v:true))
|
||||||
" Don't add any line above this, otherwise <slnum> will change.
|
" Don't add any line above this, otherwise <slnum> will change.
|
||||||
@@ -90,6 +90,7 @@ func Test_expand()
|
|||||||
set verbose=1
|
set verbose=1
|
||||||
call assert_equal("", expand('%'))
|
call assert_equal("", expand('%'))
|
||||||
set verbose=0
|
set verbose=0
|
||||||
|
call assert_equal("", expand('%:p'))
|
||||||
quit
|
quit
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
4842,
|
||||||
/**/
|
/**/
|
||||||
4841,
|
4841,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user