Merge pull request #55 from kyazdani42/fix/remove-gotos

fix: remove goto statement to match neovim lua version
This commit is contained in:
Kiyan Yazdani 2020-07-21 17:10:27 +02:00 committed by GitHub
commit 5c809cda08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,20 +95,19 @@ function M.refresh_entries(entries, cwd)
while true do while true do
local name, t = luv.fs_scandir_next(handle) local name, t = luv.fs_scandir_next(handle)
if not name then break end if not name then break end
if should_ignore(name) then goto continue end
if t == 'directory' then if not should_ignore(name) then
table.insert(dirs, name) if t == 'directory' then
new_entries[name] = true table.insert(dirs, name)
elseif t == 'file' then new_entries[name] = true
table.insert(files, name) elseif t == 'file' then
new_entries[name] = true table.insert(files, name)
elseif t == 'link' then new_entries[name] = true
table.insert(links, name) elseif t == 'link' then
new_entries[name] = true table.insert(links, name)
new_entries[name] = true
end
end end
::continue::
end end
local idx = 1 local idx = 1
@ -127,24 +126,25 @@ function M.refresh_entries(entries, cwd)
} }
local prev = nil local prev = nil
local change_prev
for _, e in ipairs(all) do for _, e in ipairs(all) do
for _, name in ipairs(e.entries) do for _, name in ipairs(e.entries) do
chang_prev = true
if not named_entries[name] then if not named_entries[name] then
local n = e.fn(cwd, name) local n = e.fn(cwd, name)
if not e.check(n.link_to, n.absolute_path) then if e.check(n.link_to, n.absolute_path) then
goto continue 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 end
idx = 1
if prev then
idx = entries_idx[prev] + 1
end
table.insert(entries, idx, n)
entries_idx[name] = idx
cached_entries[idx] = name
end end
prev = name if chang_prev then prev = name end
::continue::
end end
end end
end end
@ -163,17 +163,16 @@ function M.populate(entries, cwd)
while true do while true do
local name, t = luv.fs_scandir_next(handle) local name, t = luv.fs_scandir_next(handle)
if not name then break end if not name then break end
if should_ignore(name) then goto continue end
if t == 'directory' then if not should_ignore(name) then
table.insert(dirs, name) if t == 'directory' then
elseif t == 'file' then table.insert(dirs, name)
table.insert(files, name) elseif t == 'file' then
elseif t == 'link' then table.insert(files, name)
table.insert(links, name) elseif t == 'link' then
table.insert(links, name)
end
end end
::continue::
end end
-- Create Nodes -- -- Create Nodes --