From df3c47032211704c3b659127a65d1eda9a6512ea Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Tue, 21 Jul 2020 11:57:13 +0200 Subject: [PATCH] fix: remove goto statement to match neovim lua version --- lua/lib/populate.lua | 69 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/lua/lib/populate.lua b/lua/lib/populate.lua index f3a4f9ee293..81480e05c2b 100644 --- a/lua/lib/populate.lua +++ b/lua/lib/populate.lua @@ -95,20 +95,19 @@ function M.refresh_entries(entries, cwd) while true do local name, t = luv.fs_scandir_next(handle) if not name then break end - if should_ignore(name) then goto continue end - - if t == 'directory' then - table.insert(dirs, name) - new_entries[name] = true - elseif t == 'file' then - table.insert(files, name) - new_entries[name] = true - elseif t == 'link' then - table.insert(links, name) - new_entries[name] = true - end - ::continue:: + if not should_ignore(name) then + if t == 'directory' then + table.insert(dirs, name) + new_entries[name] = true + elseif t == 'file' then + table.insert(files, name) + new_entries[name] = true + elseif t == 'link' then + table.insert(links, name) + new_entries[name] = true + end + end end local idx = 1 @@ -127,24 +126,25 @@ function M.refresh_entries(entries, cwd) } local prev = nil + local change_prev for _, e in ipairs(all) do for _, name in ipairs(e.entries) do + chang_prev = true if not named_entries[name] then local n = e.fn(cwd, name) - if not e.check(n.link_to, n.absolute_path) then - goto continue - end - - idx = 1 - if prev then - idx = entries_idx[prev] + 1 + if e.check(n.link_to, n.absolute_path) then + idx = 1 + if prev then + idx = entries_idx[prev] + 1 + end + table.insert(entries, idx, n) + entries_idx[name] = idx + cached_entries[idx] = name + else + chang_prev = false end - table.insert(entries, idx, n) - entries_idx[name] = idx - cached_entries[idx] = name end - prev = name - ::continue:: + if chang_prev then prev = name end end end end @@ -163,17 +163,16 @@ function M.populate(entries, cwd) while true do local name, t = luv.fs_scandir_next(handle) if not name then break end - if should_ignore(name) then goto continue end - - if t == 'directory' then - table.insert(dirs, name) - elseif t == 'file' then - table.insert(files, name) - elseif t == 'link' then - table.insert(links, name) - end - ::continue:: + if not should_ignore(name) then + if t == 'directory' then + table.insert(dirs, name) + elseif t == 'file' then + table.insert(files, name) + elseif t == 'link' then + table.insert(links, name) + end + end end -- Create Nodes --