refactor(lua): rename tbl_islist => islist

ref #24572
This commit is contained in:
Justin M. Keyes
2024-04-21 15:19:43 +02:00
parent 032df963bb
commit d9d890562e
10 changed files with 67 additions and 57 deletions

View File

@@ -82,7 +82,7 @@ local vim9 = (function()
end
M.index = function(obj, idx)
if vim.tbl_islist(obj) then
if vim.islist(obj) then
if idx < 0 then
return obj[#obj + idx + 1]
else
@@ -127,7 +127,7 @@ local vim9 = (function()
assert(type(finish) == 'number')
local slicer
if vim.tbl_islist(obj) then
if vim.islist(obj) then
slicer = vim.list_slice
elseif type(obj) == 'string' then
slicer = string.sub
@@ -168,7 +168,7 @@ local vim9 = (function()
end
M.iter = function(expr)
if vim.tbl_islist(expr) then
if vim.islist(expr) then
return ipairs(expr)
else
return pairs(expr)
@@ -234,7 +234,7 @@ vim9['convert'] = (function()
elseif type(val) == 'table' then
if vim.tbl_isempty(val) then
return vim.empty_dict()
elseif vim.tbl_islist(val) then
elseif vim.islist(val) then
error(string.format('Cannot pass list to dictionary? %s', vim.inspect(val)))
else
return val
@@ -280,7 +280,7 @@ vim9['fn'] = (function()
error("haven't written this code yet")
end
if vim.tbl_islist(right) then
if vim.islist(right) then
vim.list_extend(left, right)
return left
else

View File

@@ -642,7 +642,7 @@ end
--- @param t table<any,any>
--- @param val any
local function remove_one_item(t, val)
if vim.tbl_islist(t) then
if vim.islist(t) then
local remove_index = nil
for i, v in ipairs(t) do
if v == val then

View File

@@ -974,7 +974,7 @@ function M.set(namespace, bufnr, diagnostics, opts)
bufnr = { bufnr, 'n' },
diagnostics = {
diagnostics,
vim.tbl_islist,
vim.islist,
'a list of diagnostics',
},
opts = { opts, 't', true },
@@ -1186,7 +1186,7 @@ M.handlers.signs = {
bufnr = { bufnr, 'n' },
diagnostics = {
diagnostics,
vim.tbl_islist,
vim.islist,
'a list of diagnostics',
},
opts = { opts, 't', true },
@@ -1309,7 +1309,7 @@ M.handlers.underline = {
bufnr = { bufnr, 'n' },
diagnostics = {
diagnostics,
vim.tbl_islist,
vim.islist,
'a list of diagnostics',
},
opts = { opts, 't', true },
@@ -1382,7 +1382,7 @@ M.handlers.virtual_text = {
bufnr = { bufnr, 'n' },
diagnostics = {
diagnostics,
vim.tbl_islist,
vim.islist,
'a list of diagnostics',
},
opts = { opts, 't', true },
@@ -1576,7 +1576,7 @@ function M.show(namespace, bufnr, diagnostics, opts)
diagnostics = {
diagnostics,
function(v)
return v == nil or vim.tbl_islist(v)
return v == nil or vim.islist(v)
end,
'a list of diagnostics',
},
@@ -2120,7 +2120,7 @@ function M.toqflist(diagnostics)
vim.validate({
diagnostics = {
diagnostics,
vim.tbl_islist,
vim.islist,
'a list of diagnostics',
},
})
@@ -2160,7 +2160,7 @@ function M.fromqflist(list)
vim.validate({
list = {
list,
vim.tbl_islist,
vim.islist,
'a list of quickfix items',
},
})

View File

@@ -428,7 +428,7 @@ local function location_handler(_, result, ctx, config)
-- textDocument/definition can return Location or Location[]
-- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
if not vim.tbl_islist(result) then
if not vim.islist(result) then
result = { result }
end

View File

@@ -601,7 +601,7 @@ end
--- Tests if `t` is an "array": a table indexed _only_ by integers (potentially non-contiguous).
---
--- If the indexes start from 1 and are contiguous then the array is also a list. |vim.tbl_islist()|
--- If the indexes start from 1 and are contiguous then the array is also a list. |vim.islist()|
---
--- Empty table `{}` is an array, unless it was created by |vim.empty_dict()| or returned as
--- a dict-like |API| or Vimscript result, for example from |rpcrequest()| or |vim.fn|.
@@ -640,6 +640,12 @@ function vim.tbl_isarray(t)
end
end
--- @deprecated
function vim.tbl_islist(t)
vim.deprecate('vim.tbl_islist', 'vim.islist', '0.12')
return vim.islist(t)
end
--- Tests if `t` is a "list": a table indexed _only_ by contiguous integers starting from 1 (what
--- |lua-length| calls a "regular array").
---
@@ -648,9 +654,9 @@ end
---
---@see |vim.tbl_isarray()|
---
---@param t table
---@param t? table
---@return boolean `true` if list-like table, else `false`.
function vim.tbl_islist(t)
function vim.islist(t)
if type(t) ~= 'table' then
return false
end