Mercurial > vim
changeset 10912:fd1760f8c215 v8.0.0345
patch 8.0.0345: islocked('d.changedtick') does not work
commit https://github.com/vim/vim/commit/3a257737726ba42980bf38ec9a0c80944756af24
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 21 20:47:13 2017 +0100
patch 8.0.0345: islocked('d.changedtick') does not work
Problem: islocked('d.changedtick') does not work.
Solution: Make it work.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 21 Feb 2017 21:00:04 +0100 |
parents | 09f200404633 |
children | a9198ff3329a |
files | src/buffer.c src/eval.c src/evalfunc.c src/testdir/test_changedtick.vim src/version.c src/vim.h |
diffstat | 6 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buffer.c +++ b/src/buffer.c @@ -884,7 +884,7 @@ init_changedtick(buf_T *buf) if (di != NULL) { - di->di_flags |= DI_FLAGS_LOCK | DI_FLAGS_FIX | DI_FLAGS_RO; + di->di_flags |= DI_FLAGS_FIX | DI_FLAGS_RO; di->di_tv.v_type = VAR_NUMBER; di->di_tv.v_lock = VAR_FIXED; di->di_tv.vval.v_number = 0;
--- a/src/eval.c +++ b/src/eval.c @@ -1811,6 +1811,7 @@ ex_let_one( * * flags: * GLV_QUIET: do not give error messages + * GLV_READ_ONLY: will not change the variable * GLV_NO_AUTOLOAD: do not use script autoloading * * Returns a pointer to just after the name, including indexes. @@ -2078,7 +2079,8 @@ get_lval( break; } /* existing variable, need to check if it can be changed */ - else if (var_check_ro(lp->ll_di->di_flags, name, FALSE)) + else if ((flags & GLV_READ_ONLY) == 0 + && var_check_ro(lp->ll_di->di_flags, name, FALSE)) { clear_tv(&var1); return NULL;
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6561,7 +6561,7 @@ f_islocked(typval_T *argvars, typval_T * rettv->vval.v_number = -1; end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE, - GLV_NO_AUTOLOAD, FNE_CHECK_START); + GLV_NO_AUTOLOAD | GLV_READ_ONLY, FNE_CHECK_START); if (end != NULL && lv.ll_name != NULL) { if (*end != NUL)
--- a/src/testdir/test_changedtick.vim +++ b/src/testdir/test_changedtick.vim @@ -32,6 +32,12 @@ func Test_changedtick_bdel() call assert_equal(v + 1, getbufvar(bnr, 'changedtick')) endfunc +func Test_changedtick_islocked() + call assert_equal(0, islocked('b:changedtick')) + let d = b: + call assert_equal(0, islocked('d.changedtick')) +endfunc + func Test_changedtick_fixed() call assert_fails('let b:changedtick = 4', 'E46:') call assert_fails('let b:["changedtick"] = 4', 'E46:')
--- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 345, +/**/ 344, /**/ 343,
--- a/src/vim.h +++ b/src/vim.h @@ -2474,10 +2474,12 @@ typedef enum { #define TFN_QUIET 2 /* no error messages */ #define TFN_NO_AUTOLOAD 4 /* do not use script autoloading */ #define TFN_NO_DEREF 8 /* do not dereference a Funcref */ +#define TFN_READ_ONLY 16 /* will not change the var */ /* Values for get_lval() flags argument: */ #define GLV_QUIET TFN_QUIET /* no error messages */ #define GLV_NO_AUTOLOAD TFN_NO_AUTOLOAD /* do not use script autoloading */ +#define GLV_READ_ONLY TFN_READ_ONLY /* will not change the var */ #define DO_NOT_FREE_CNT 99999 /* refcount for dict or list that should not be freed. */