Skip to content

Commit 7bd3816

Browse files
committed
chore(#3196): move utils.table_create_missing to legacy
1 parent 748aff5 commit 7bd3816

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

lua/nvim-tree/legacy.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ local notify = require("nvim-tree.notify")
22

33
local M = {}
44

5+
--- Create empty sub-tables if not present
6+
---@param tbl table to create empty inside of
7+
---@param path string dot separated string of sub-tables
8+
---@return table deepest sub-table
9+
local function create(tbl, path)
10+
local t = tbl
11+
for s in string.gmatch(path, "([^%.]+)%.*") do
12+
if t[s] == nil then
13+
t[s] = {}
14+
end
15+
t = t[s]
16+
end
17+
18+
return t
19+
end
20+
521
--- Move a value from src to dst if value is nil on dst.
622
--- Remove value from src
723
---@param src table to copy from
@@ -24,7 +40,7 @@ local function move(src, src_path, src_pos, dst, dst_path, dst_pos, remove)
2440
return
2541
end
2642

27-
dst = M.table_create_missing(dst, dst_path)
43+
dst = create(dst, dst_path)
2844
if dst[dst_pos] == nil then
2945
dst[dst_pos] = src_val
3046
end

lua/nvim-tree/utils.lua

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -361,22 +361,6 @@ function M.escape_special_chars(path)
361361
return M.is_windows and escape_special_char_for_windows(path) or path
362362
end
363363

364-
--- Create empty sub-tables if not present
365-
---@param tbl table to create empty inside of
366-
---@param path string dot separated string of sub-tables
367-
---@return table deepest sub-table
368-
function M.table_create_missing(tbl, path)
369-
local t = tbl
370-
for s in string.gmatch(path, "([^%.]+)%.*") do
371-
if t[s] == nil then
372-
t[s] = {}
373-
end
374-
t = t[s]
375-
end
376-
377-
return t
378-
end
379-
380364
local function round(value)
381365
-- Amount of digits to round to after floating point.
382366
local digits = 2

0 commit comments

Comments
 (0)