1
0
forked from aniani/vim

patch 8.2.4726: cannot use expand() to get the script name

Problem:    Cannot use expand() to get the script name.
Solution:   Support expand('<script>'). (closes #10121)
This commit is contained in:
LemonBoy
2022-04-09 21:42:10 +01:00
committed by Bram Moolenaar
parent 2ce97ae6aa
commit 6013d0045d
7 changed files with 114 additions and 10 deletions

View File

@@ -8957,8 +8957,10 @@ find_cmdline_var(char_u *src, int *usedlen)
#define SPEC_SLNUM (SPEC_SFILE + 1)
"<stack>", // call stack
#define SPEC_STACK (SPEC_SLNUM + 1)
"<script>", // script file name
#define SPEC_SCRIPT (SPEC_STACK + 1)
"<afile>", // autocommand file name
#define SPEC_AFILE (SPEC_STACK + 1)
#define SPEC_AFILE (SPEC_SCRIPT + 1)
"<abuf>", // autocommand buffer number
#define SPEC_ABUF (SPEC_AFILE + 1)
"<amatch>", // autocommand match name
@@ -9226,14 +9228,28 @@ eval_vars(
break;
case SPEC_SFILE: // file name for ":so" command
case SPEC_STACK: // call stack
result = estack_sfile(spec_idx == SPEC_SFILE
? ESTACK_SFILE : ESTACK_STACK);
result = estack_sfile(ESTACK_SFILE);
if (result == NULL)
{
*errormsg = spec_idx == SPEC_SFILE
? _(e_no_source_file_name_to_substitute_for_sfile)
: _(e_no_call_stack_to_substitute_for_stack);
*errormsg = _(e_no_source_file_name_to_substitute_for_sfile);
return NULL;
}
resultbuf = result; // remember allocated string
break;
case SPEC_STACK: // call stack
result = estack_sfile(ESTACK_STACK);
if (result == NULL)
{
*errormsg = _(e_no_call_stack_to_substitute_for_stack);
return NULL;
}
resultbuf = result; // remember allocated string
break;
case SPEC_SCRIPT: // script file name
result = estack_sfile(ESTACK_SCRIPT);
if (result == NULL)
{
*errormsg = _(e_no_script_file_name_to_substitute_for_script);
return NULL;
}
resultbuf = result; // remember allocated string