mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1190: Vim9: checking for Vim9 syntax is spread out
Problem: Vim9: checking for Vim9 syntax is spread out. Solution: Use in_vim9script().
This commit is contained in:
@@ -729,7 +729,7 @@ ex_let(exarg_T *eap)
|
||||
emsg(_("E985: .= is not supported with script version 2"));
|
||||
else if (!ends_excmd2(eap->cmd, arg))
|
||||
{
|
||||
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
|
||||
if (in_vim9script())
|
||||
{
|
||||
// Vim9 declaration ":let var: type"
|
||||
arg = vim9_declare_scriptvar(eap, arg);
|
||||
@@ -993,7 +993,7 @@ skip_var_one(char_u *arg, int include_type)
|
||||
return arg + 2;
|
||||
end = find_name_end(*arg == '$' || *arg == '&' ? arg + 1 : arg,
|
||||
NULL, NULL, FNE_INCL_BR | FNE_CHECK_START);
|
||||
if (include_type && current_sctx.sc_version == SCRIPT_VERSION_VIM9)
|
||||
if (include_type && in_vim9script())
|
||||
{
|
||||
// "a: type" is declaring variable "a" with a type, not "a:".
|
||||
if (end == arg + 2 && end[-1] == ':')
|
||||
@@ -1212,8 +1212,7 @@ ex_let_one(
|
||||
emsg(_("E996: Cannot lock an environment variable"));
|
||||
return NULL;
|
||||
}
|
||||
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9
|
||||
&& (flags & LET_NO_COMMAND) == 0)
|
||||
if (in_vim9script() && (flags & LET_NO_COMMAND) == 0)
|
||||
{
|
||||
vim9_declare_error(arg);
|
||||
return NULL;
|
||||
@@ -1576,8 +1575,7 @@ do_unlet(char_u *name, int forceit)
|
||||
dict_T *d;
|
||||
dictitem_T *di;
|
||||
|
||||
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9
|
||||
&& check_vim9_unlet(name) == FAIL)
|
||||
if (in_vim9script() && check_vim9_unlet(name) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
ht = find_var_ht(name, &varname);
|
||||
@@ -2392,8 +2390,7 @@ eval_variable(
|
||||
*dip = v;
|
||||
}
|
||||
|
||||
if (tv == NULL && (current_sctx.sc_version == SCRIPT_VERSION_VIM9
|
||||
|| STRNCMP(name, "s:", 2) == 0))
|
||||
if (tv == NULL && (in_vim9script() || STRNCMP(name, "s:", 2) == 0))
|
||||
{
|
||||
imported_T *import;
|
||||
char_u *p = STRNCMP(name, "s:", 2) == 0 ? name + 2 : name;
|
||||
@@ -2634,7 +2631,7 @@ find_var_ht(char_u *name, char_u **varname)
|
||||
return ht; // local variable
|
||||
|
||||
// in Vim9 script items at the script level are script-local
|
||||
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
|
||||
if (in_vim9script())
|
||||
{
|
||||
ht = get_script_local_ht();
|
||||
if (ht != NULL)
|
||||
@@ -2897,7 +2894,7 @@ set_var_const(
|
||||
}
|
||||
is_script_local = ht == get_script_local_ht();
|
||||
|
||||
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9
|
||||
if (in_vim9script()
|
||||
&& !is_script_local
|
||||
&& (flags & LET_NO_COMMAND) == 0
|
||||
&& name[1] == ':')
|
||||
@@ -2926,8 +2923,7 @@ set_var_const(
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_script_local
|
||||
&& current_sctx.sc_version == SCRIPT_VERSION_VIM9)
|
||||
if (is_script_local && in_vim9script())
|
||||
{
|
||||
if ((flags & LET_NO_COMMAND) == 0)
|
||||
{
|
||||
@@ -3023,7 +3019,7 @@ set_var_const(
|
||||
if (flags & LET_IS_CONST)
|
||||
di->di_flags |= DI_FLAGS_LOCK;
|
||||
|
||||
if (is_script_local && current_sctx.sc_version == SCRIPT_VERSION_VIM9)
|
||||
if (is_script_local && in_vim9script())
|
||||
{
|
||||
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
|
||||
|
||||
|
Reference in New Issue
Block a user