File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -1344,11 +1344,31 @@ function M.merge_sort(t, comparator)
1344
1344
split_merge (t , 1 , # t , comparator )
1345
1345
end
1346
1346
1347
- M .islist = vim .fn .has (" nvim-0.10" ) == 1 and vim .islist or vim .tbl_islist --- @diagnostic disable-line : deprecated
1347
+ --- @diagnostic disable-next-line : deprecated
1348
+ M .islist = vim .fn .has (" nvim-0.10" ) == 1 and vim .islist or vim .tbl_islist
1348
1349
1349
- M .flatten = vim .fn .has (" nvim-0.10" ) == 1 and function (...)
1350
- return vim .iter (... ):flatten (math.huge ):totable ()
1351
- end or vim .tbl_flatten --- @diagnostic disable-line : deprecated
1350
+ --- @param t table
1351
+ --- @return any[]
1352
+ function M .flatten (t )
1353
+ local result = {}
1354
+
1355
+ --- @param _t table<any,any>
1356
+ local function recurse (_t )
1357
+ local n = # _t
1358
+ for i = 1 , n do
1359
+ local v = _t [i ]
1360
+ if type (v ) == ' table' then
1361
+ recurse (v )
1362
+ elseif v then
1363
+ table.insert (result , v )
1364
+ end
1365
+ end
1366
+ end
1367
+
1368
+ recurse (t )
1369
+
1370
+ return result
1371
+ end
1352
1372
1353
1373
M .path_sep = path_sep
1354
1374
You can’t perform that action at this time.
0 commit comments