Move to non deprecated function calls (#1930)
* Move to non deprecated function calls * Keeping it compatible with older versions
This commit is contained in:
committed by
GitHub
parent
31a2939e55
commit
abacd4cb7f
@@ -1,5 +1,7 @@
|
|||||||
local misc = {}
|
local misc = {}
|
||||||
|
|
||||||
|
local islist = vim.islist or vim.tbl_islist
|
||||||
|
|
||||||
---Create once callback
|
---Create once callback
|
||||||
---@param callback function
|
---@param callback function
|
||||||
---@return function
|
---@return function
|
||||||
@@ -88,8 +90,8 @@ misc.none = vim.NIL
|
|||||||
---@param tbl2 T
|
---@param tbl2 T
|
||||||
---@return T
|
---@return T
|
||||||
misc.merge = function(tbl1, tbl2)
|
misc.merge = function(tbl1, tbl2)
|
||||||
local is_dict1 = type(tbl1) == 'table' and (not vim.tbl_islist(tbl1) or vim.tbl_isempty(tbl1))
|
local is_dict1 = type(tbl1) == 'table' and (not islist(tbl1) or vim.tbl_isempty(tbl1))
|
||||||
local is_dict2 = type(tbl2) == 'table' and (not vim.tbl_islist(tbl2) or vim.tbl_isempty(tbl2))
|
local is_dict2 = type(tbl2) == 'table' and (not islist(tbl2) or vim.tbl_isempty(tbl2))
|
||||||
if is_dict1 and is_dict2 then
|
if is_dict1 and is_dict2 then
|
||||||
local new_tbl = {}
|
local new_tbl = {}
|
||||||
for k, v in pairs(tbl2) do
|
for k, v in pairs(tbl2) do
|
||||||
@@ -163,7 +165,7 @@ misc.copy = function(tbl)
|
|||||||
return tbl
|
return tbl
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.tbl_islist(tbl) then
|
if islist(tbl) then
|
||||||
local copy = {}
|
local copy = {}
|
||||||
for i, value in ipairs(tbl) do
|
for i, value in ipairs(tbl) do
|
||||||
copy[i] = misc.copy(value)
|
copy[i] = misc.copy(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user