mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
refactor(lua): deprecate tbl_flatten
Problem: Besides being redundant with vim.iter():flatten(), `tbl_flatten` has these problems: - Has `tbl_` prefix but only accepts lists. - Discards some results! Compare the following: - iter.flatten(): ``` vim.iter({1, { { a = 2 } }, { 3 } }):flatten():totable() ``` - tbl_flatten: ``` vim.tbl_flatten({1, { { a = 2 } }, { 3 } }) ``` Solution: Deprecate tbl_flatten. Note: iter:flatten() currently fails ("flatten() requires a list-like table") on this code from gen_lsp.lua: local anonym = vim.iter({ -- remove nil anonymous_num > 1 and '' or nil, '---@class ' .. anonymous_classname, }):flatten():totable() Should we enhance :flatten() to work for arrays?
This commit is contained in:
@ -722,7 +722,7 @@ local wait_result_reason = { [-1] = 'timeout', [-2] = 'interrupted', [-3] = 'err
|
||||
---
|
||||
--- @param ... string List to write to the buffer
|
||||
local function err_message(...)
|
||||
local message = table.concat(vim.tbl_flatten({ ... }))
|
||||
local message = table.concat(vim.iter({ ... }):flatten():totable())
|
||||
if vim.in_fast_event() then
|
||||
vim.schedule(function()
|
||||
api.nvim_err_writeln(message)
|
||||
|
Reference in New Issue
Block a user