Skip to content

fix: remove goto statement to match neovim lua version #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 34 additions & 35 deletions lua/lib/populate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 --
Expand Down