Skip to content

Commit 3a25773

Browse files
committed
patch 8.0.0345: islocked('d.changedtick') does not work
Problem: islocked('d.changedtick') does not work. Solution: Make it work.
1 parent 49439c4 commit 3a25773

File tree

6 files changed

+15
-3
lines changed

6 files changed

+15
-3
lines changed

src/buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ init_changedtick(buf_T *buf)
884884

885885
if (di != NULL)
886886
{
887-
di->di_flags |= DI_FLAGS_LOCK | DI_FLAGS_FIX | DI_FLAGS_RO;
887+
di->di_flags |= DI_FLAGS_FIX | DI_FLAGS_RO;
888888
di->di_tv.v_type = VAR_NUMBER;
889889
di->di_tv.v_lock = VAR_FIXED;
890890
di->di_tv.vval.v_number = 0;

src/eval.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,7 @@ ex_let_one(
18111811
*
18121812
* flags:
18131813
* GLV_QUIET: do not give error messages
1814+
* GLV_READ_ONLY: will not change the variable
18141815
* GLV_NO_AUTOLOAD: do not use script autoloading
18151816
*
18161817
* Returns a pointer to just after the name, including indexes.
@@ -2078,7 +2079,8 @@ get_lval(
20782079
break;
20792080
}
20802081
/* existing variable, need to check if it can be changed */
2081-
else if (var_check_ro(lp->ll_di->di_flags, name, FALSE))
2082+
else if ((flags & GLV_READ_ONLY) == 0
2083+
&& var_check_ro(lp->ll_di->di_flags, name, FALSE))
20822084
{
20832085
clear_tv(&var1);
20842086
return NULL;

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6561,7 +6561,7 @@ f_islocked(typval_T *argvars, typval_T *rettv)
65616561

65626562
rettv->vval.v_number = -1;
65636563
end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE,
6564-
GLV_NO_AUTOLOAD, FNE_CHECK_START);
6564+
GLV_NO_AUTOLOAD | GLV_READ_ONLY, FNE_CHECK_START);
65656565
if (end != NULL && lv.ll_name != NULL)
65666566
{
65676567
if (*end != NUL)

src/testdir/test_changedtick.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ func Test_changedtick_bdel()
3232
call assert_equal(v + 1, getbufvar(bnr, 'changedtick'))
3333
endfunc
3434

35+
func Test_changedtick_islocked()
36+
call assert_equal(0, islocked('b:changedtick'))
37+
let d = b:
38+
call assert_equal(0, islocked('d.changedtick'))
39+
endfunc
40+
3541
func Test_changedtick_fixed()
3642
call assert_fails('let b:changedtick = 4', 'E46:')
3743
call assert_fails('let b:["changedtick"] = 4', 'E46:')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
345,
767769
/**/
768770
344,
769771
/**/

src/vim.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,10 +2474,12 @@ typedef enum {
24742474
#define TFN_QUIET 2 /* no error messages */
24752475
#define TFN_NO_AUTOLOAD 4 /* do not use script autoloading */
24762476
#define TFN_NO_DEREF 8 /* do not dereference a Funcref */
2477+
#define TFN_READ_ONLY 16 /* will not change the var */
24772478

24782479
/* Values for get_lval() flags argument: */
24792480
#define GLV_QUIET TFN_QUIET /* no error messages */
24802481
#define GLV_NO_AUTOLOAD TFN_NO_AUTOLOAD /* do not use script autoloading */
2482+
#define GLV_READ_ONLY TFN_READ_ONLY /* will not change the var */
24812483

24822484
#define DO_NOT_FREE_CNT 99999 /* refcount for dict or list that should not
24832485
be freed. */

0 commit comments

Comments
 (0)