mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
eval: Make sure that b:changedtick may not be unlocked via :unlo b:var
It still may be unlocked by `:unlock b:.var`.
This commit is contained in:
parent
908e53d98d
commit
f2c9fd312c
@ -170,6 +170,8 @@ static char *e_letwrong = N_("E734: Wrong variable type for %s=");
|
|||||||
static char *e_nofunc = N_("E130: Unknown function: %s");
|
static char *e_nofunc = N_("E130: Unknown function: %s");
|
||||||
static char *e_illvar = N_("E461: Illegal variable name: %s");
|
static char *e_illvar = N_("E461: Illegal variable name: %s");
|
||||||
static char *e_float_as_string = N_("E806: using Float as a String");
|
static char *e_float_as_string = N_("E806: using Float as a String");
|
||||||
|
static const char *e_readonlyvar = N_(
|
||||||
|
"E46: Cannot change read-only variable \"%.*s\"");
|
||||||
|
|
||||||
static char_u * const empty_string = (char_u *)"";
|
static char_u * const empty_string = (char_u *)"";
|
||||||
static char_u * const namespace_char = (char_u *)"abglstvw";
|
static char_u * const namespace_char = (char_u *)"abglstvw";
|
||||||
@ -3057,29 +3059,33 @@ int do_unlet(char_u *name, int forceit)
|
|||||||
static int do_lock_var(lval_T *lp, char_u *name_end, int deep, int lock)
|
static int do_lock_var(lval_T *lp, char_u *name_end, int deep, int lock)
|
||||||
{
|
{
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
int cc;
|
|
||||||
dictitem_T *di;
|
|
||||||
|
|
||||||
if (deep == 0) /* nothing to do */
|
if (deep == 0) { // Nothing to do.
|
||||||
return OK;
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (lp->ll_tv == NULL) {
|
if (lp->ll_tv == NULL) {
|
||||||
cc = *name_end;
|
|
||||||
*name_end = NUL;
|
|
||||||
|
|
||||||
// Normal name or expanded name.
|
// Normal name or expanded name.
|
||||||
di = find_var((const char *)lp->ll_name, STRLEN(lp->ll_name), NULL, true);
|
const size_t name_len = (size_t)(name_end - lp->ll_name);
|
||||||
|
dictitem_T *const di = find_var(
|
||||||
|
(const char *)lp->ll_name, name_len, NULL,
|
||||||
|
true);
|
||||||
if (di == NULL) {
|
if (di == NULL) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
} else {
|
} else {
|
||||||
if (lock) {
|
if ((di->di_flags & (DI_FLAGS_LOCK|DI_FLAGS_FIX))
|
||||||
|
== (DI_FLAGS_LOCK|DI_FLAGS_FIX)) {
|
||||||
|
// Locked and fixed: do not alter lock, but issue an error.
|
||||||
|
// Provides compatibility with former `unlockvar b:changedtick`
|
||||||
|
// behaviour.
|
||||||
|
emsgf(_(e_readonlyvar), (int)name_len, lp->ll_name);
|
||||||
|
} else if (lock) {
|
||||||
di->di_flags |= DI_FLAGS_LOCK;
|
di->di_flags |= DI_FLAGS_LOCK;
|
||||||
} else {
|
} else {
|
||||||
di->di_flags &= ~DI_FLAGS_LOCK;
|
di->di_flags &= ~DI_FLAGS_LOCK;
|
||||||
}
|
}
|
||||||
item_lock(&di->di_tv, deep, lock);
|
item_lock(&di->di_tv, deep, lock);
|
||||||
}
|
}
|
||||||
*name_end = cc;
|
|
||||||
} else if (lp->ll_range) {
|
} else if (lp->ll_range) {
|
||||||
listitem_T *li = lp->ll_li;
|
listitem_T *li = lp->ll_li;
|
||||||
|
|
||||||
@ -20542,7 +20548,9 @@ set_var (
|
|||||||
static bool var_check_ro(int flags, char_u *name, bool use_gettext)
|
static bool var_check_ro(int flags, char_u *name, bool use_gettext)
|
||||||
{
|
{
|
||||||
if (flags & DI_FLAGS_RO) {
|
if (flags & DI_FLAGS_RO) {
|
||||||
EMSG2(_(e_readonlyvar), use_gettext ? (char_u *)_(name) : name);
|
const char_u *const name_translated = (
|
||||||
|
use_gettext ? (char_u *)_(name) : name);
|
||||||
|
emsgf(_(e_readonlyvar), (int)STRLEN(name_translated), name_translated);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((flags & DI_FLAGS_RO_SBX) && sandbox) {
|
if ((flags & DI_FLAGS_RO_SBX) && sandbox) {
|
||||||
|
@ -1173,8 +1173,6 @@ EXTERN char_u e_re_damg[] INIT(= N_("E43: Damaged match string"));
|
|||||||
EXTERN char_u e_re_corr[] INIT(= N_("E44: Corrupted regexp program"));
|
EXTERN char_u e_re_corr[] INIT(= N_("E44: Corrupted regexp program"));
|
||||||
EXTERN char_u e_readonly[] INIT(= N_(
|
EXTERN char_u e_readonly[] INIT(= N_(
|
||||||
"E45: 'readonly' option is set (add ! to override)"));
|
"E45: 'readonly' option is set (add ! to override)"));
|
||||||
EXTERN char_u e_readonlyvar[] INIT(= N_(
|
|
||||||
"E46: Cannot change read-only variable \"%s\""));
|
|
||||||
EXTERN char_u e_readonlysbx[] INIT(= N_(
|
EXTERN char_u e_readonlysbx[] INIT(= N_(
|
||||||
"E794: Cannot set variable in the sandbox: \"%s\""));
|
"E794: Cannot set variable in the sandbox: \"%s\""));
|
||||||
EXTERN char_u e_readerrf[] INIT(= N_("E47: Error while reading errorfile"));
|
EXTERN char_u e_readerrf[] INIT(= N_("E47: Error while reading errorfile"));
|
||||||
|
@ -95,8 +95,17 @@ describe('b:changedtick', function()
|
|||||||
redir_exec(':let b:'))
|
redir_exec(':let b:'))
|
||||||
end)
|
end)
|
||||||
it('fails to unlock b:changedtick', function()
|
it('fails to unlock b:changedtick', function()
|
||||||
|
eq(0, exc_exec('let d = b:'))
|
||||||
|
eq(1, funcs.islocked('b:changedtick'))
|
||||||
-- FIXME
|
-- FIXME
|
||||||
-- eq('\nE', redir_exec('unlockvar b:changedtick'))
|
-- eq(1, funcs.islocked('d.changedtick'))
|
||||||
|
eq('\nE46: Cannot change read-only variable "b:changedtick"',
|
||||||
|
redir_exec('unlockvar b:changedtick'))
|
||||||
|
-- FIXME
|
||||||
|
-- eq('\nE46: Cannot change read-only variable "b:changedtick"',
|
||||||
|
-- redir_exec('unlockvar d.changedtick'))
|
||||||
|
eq(1, funcs.islocked('b:changedtick'))
|
||||||
|
-- eq(1, funcs.islocked('d.changedtick'))
|
||||||
end)
|
end)
|
||||||
it('is being completed', function()
|
it('is being completed', function()
|
||||||
feed(':echo b:<Tab><Home>let cmdline="<End>"<CR>')
|
feed(':echo b:<Tab><Home>let cmdline="<End>"<CR>')
|
||||||
|
Loading…
Reference in New Issue
Block a user