Mercurial > vim
diff src/evalvars.c @ 27394:69a48bcd1d80 v8.2.4225
patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Commit: https://github.com/vim/vim/commit/70c43d84be98ab54d3723155dcc4232dc5a5f081
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 26 21:01:15 2022 +0000
patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Problem: Vim9: depth argument of :lockvar not parsed in :def function.
Solution: Parse the optional depth argument. (closes https://github.com/vim/vim/issues/9629)
Fix that locking doesn't work for a non-materialize list.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 26 Jan 2022 22:15:03 +0100 |
parents | 2ca6dd1f62af |
children | a14c4d3e3260 |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -2060,10 +2060,18 @@ item_lock(typval_T *tv, int deep, int lo l->lv_lock |= VAR_LOCKED; else l->lv_lock &= ~VAR_LOCKED; - if ((deep < 0 || deep > 1) && l->lv_first != &range_list_item) - // recursive: lock/unlock the items the List contains - FOR_ALL_LIST_ITEMS(l, li) - item_lock(&li->li_tv, deep - 1, lock, check_refcount); + if (deep < 0 || deep > 1) + { + if (l->lv_first == &range_list_item) + l->lv_lock |= VAR_ITEMS_LOCKED; + else + { + // recursive: lock/unlock the items the List contains + CHECK_LIST_MATERIALIZE(l); + FOR_ALL_LIST_ITEMS(l, li) item_lock(&li->li_tv, + deep - 1, lock, check_refcount); + } + } } break; case VAR_DICT: