Skip to content

Commit df3c470

Browse files
committed
fix: remove goto statement to match neovim lua version
1 parent 8e0eff2 commit df3c470

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

lua/lib/populate.lua

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,19 @@ function M.refresh_entries(entries, cwd)
9595
while true do
9696
local name, t = luv.fs_scandir_next(handle)
9797
if not name then break end
98-
if should_ignore(name) then goto continue end
99-
100-
if t == 'directory' then
101-
table.insert(dirs, name)
102-
new_entries[name] = true
103-
elseif t == 'file' then
104-
table.insert(files, name)
105-
new_entries[name] = true
106-
elseif t == 'link' then
107-
table.insert(links, name)
108-
new_entries[name] = true
109-
end
11098

111-
::continue::
99+
if not should_ignore(name) then
100+
if t == 'directory' then
101+
table.insert(dirs, name)
102+
new_entries[name] = true
103+
elseif t == 'file' then
104+
table.insert(files, name)
105+
new_entries[name] = true
106+
elseif t == 'link' then
107+
table.insert(links, name)
108+
new_entries[name] = true
109+
end
110+
end
112111
end
113112

114113
local idx = 1
@@ -127,24 +126,25 @@ function M.refresh_entries(entries, cwd)
127126
}
128127

129128
local prev = nil
129+
local change_prev
130130
for _, e in ipairs(all) do
131131
for _, name in ipairs(e.entries) do
132+
chang_prev = true
132133
if not named_entries[name] then
133134
local n = e.fn(cwd, name)
134-
if not e.check(n.link_to, n.absolute_path) then
135-
goto continue
136-
end
137-
138-
idx = 1
139-
if prev then
140-
idx = entries_idx[prev] + 1
135+
if e.check(n.link_to, n.absolute_path) then
136+
idx = 1
137+
if prev then
138+
idx = entries_idx[prev] + 1
139+
end
140+
table.insert(entries, idx, n)
141+
entries_idx[name] = idx
142+
cached_entries[idx] = name
143+
else
144+
chang_prev = false
141145
end
142-
table.insert(entries, idx, n)
143-
entries_idx[name] = idx
144-
cached_entries[idx] = name
145146
end
146-
prev = name
147-
::continue::
147+
if chang_prev then prev = name end
148148
end
149149
end
150150
end
@@ -163,17 +163,16 @@ function M.populate(entries, cwd)
163163
while true do
164164
local name, t = luv.fs_scandir_next(handle)
165165
if not name then break end
166-
if should_ignore(name) then goto continue end
167-
168-
if t == 'directory' then
169-
table.insert(dirs, name)
170-
elseif t == 'file' then
171-
table.insert(files, name)
172-
elseif t == 'link' then
173-
table.insert(links, name)
174-
end
175166

176-
::continue::
167+
if not should_ignore(name) then
168+
if t == 'directory' then
169+
table.insert(dirs, name)
170+
elseif t == 'file' then
171+
table.insert(files, name)
172+
elseif t == 'link' then
173+
table.insert(links, name)
174+
end
175+
end
177176
end
178177

179178
-- Create Nodes --

0 commit comments

Comments
 (0)