Mercurial > vim
comparison src/if_lua.c @ 21060:89aba7895bb2 v8.2.1081
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Commit: https://github.com/vim/vim/commit/a1f9f8666ed3a462eb8a518e78418c57dc41bbd4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 28 22:41:26 2020 +0200
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Problem: Lua: cannot use table.insert() and table.remove().
Solution: Add the list functions. (Prabir Shrestha, closes https://github.com/vim/vim/issues/6353)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Jun 2020 22:45:04 +0200 |
parents | 08e284594211 |
children | 43e82e8133b9 |
comparison
equal
deleted
inserted
replaced
21059:90872dbd2bfe | 21060:89aba7895bb2 |
---|---|
911 n -= 1; | 911 n -= 1; |
912 | 912 |
913 if (l->lv_lock) | 913 if (l->lv_lock) |
914 luaL_error(L, "list is locked"); | 914 luaL_error(L, "list is locked"); |
915 li = list_find(l, n); | 915 li = list_find(l, n); |
916 if (li == NULL) return 0; | 916 if (li == NULL) |
917 if (lua_isnil(L, 3)) // remove? | 917 { |
918 { | 918 if (!lua_isnil(L, 3)) |
919 vimlist_remove(l, li, li); | 919 { |
920 listitem_free(l, li); | 920 typval_T v; |
921 luaV_checktypval(L, 3, &v, "inserting list item"); | |
922 if (list_insert_tv(l, &v, li) == FAIL) | |
923 luaL_error(L, "failed to add item to list"); | |
924 clear_tv(&v); | |
925 } | |
921 } | 926 } |
922 else | 927 else |
923 { | 928 { |
924 typval_T v; | 929 if (lua_isnil(L, 3)) // remove? |
925 luaV_checktypval(L, 3, &v, "setting list item"); | 930 { |
926 clear_tv(&li->li_tv); | 931 vimlist_remove(l, li, li); |
927 copy_tv(&v, &li->li_tv); | 932 listitem_free(l, li); |
928 clear_tv(&v); | 933 } |
934 else | |
935 { | |
936 typval_T v; | |
937 luaV_checktypval(L, 3, &v, "setting list item"); | |
938 clear_tv(&li->li_tv); | |
939 copy_tv(&v, &li->li_tv); | |
940 clear_tv(&v); | |
941 } | |
929 } | 942 } |
930 return 0; | 943 return 0; |
931 } | 944 } |
932 | 945 |
933 static int | 946 static int |