mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
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 vim/vim#10311)
211a5bb235
This commit is contained in:
@@ -6891,12 +6891,14 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
// xgettext:no-c-format
|
if (valid != VALID_HEAD + VALID_PATH) {
|
||||||
*errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\"");
|
// xgettext:no-c-format
|
||||||
} else {
|
*errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\"");
|
||||||
*errormsg = _("E500: Evaluates to an empty string");
|
} else {
|
||||||
|
*errormsg = _("E500: Evaluates to an empty string");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result = NULL;
|
result = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -107,7 +107,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.
|
||||||
@@ -115,6 +115,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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user