Skip to content

Commit 310ac0b

Browse files
committed
fix: add compatibility for Lua 5.1
Some architectures don't support LuaJIT. Remove the goto's from the code to be compatible with Neovim built without LuaJIT. Signed-off-by: Julian Ruess <[email protected]>
1 parent a6cea1a commit 310ac0b

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

lua/oil/mutator/parser.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ M.parse = function(bufnr)
192192
seen_names[name] = true
193193
end
194194
end
195+
195196
for i, line in ipairs(lines) do
197+
-- hack to be compatible with Lua 5.1
198+
-- use return instead of goto
199+
(function ()
196200
if line:match("^/%d+") then
197201
-- Parse the line for an existing entry
198202
local result, err = M.parse_line(adapter, line, column_defs)
@@ -203,10 +207,10 @@ M.parse = function(bufnr)
203207
end_lnum = i,
204208
col = 0,
205209
})
206-
goto continue
210+
return
207211
elseif result.data.id == 0 then
208212
-- Ignore entries with ID 0 (typically the "../" entry)
209-
goto continue
213+
return
210214
end
211215
local parsed_entry = result.data
212216
local entry = result.entry
@@ -226,7 +230,7 @@ M.parse = function(bufnr)
226230
end_lnum = i,
227231
col = 0,
228232
})
229-
goto continue
233+
return
230234
end
231235
assert(entry)
232236

@@ -281,7 +285,7 @@ M.parse = function(bufnr)
281285
end_lnum = i,
282286
col = 0,
283287
})
284-
goto continue
288+
return
285289
end
286290
if name ~= "" then
287291
local link_pieces = vim.split(name, " -> ", { plain = true })
@@ -300,7 +304,7 @@ M.parse = function(bufnr)
300304
})
301305
end
302306
end
303-
::continue::
307+
end)()
304308
end
305309

306310
for name, child_id in pairs(original_entries) do

lua/oil/view.lua

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -618,19 +618,17 @@ local function render_buffer(bufnr, opts)
618618
end
619619

620620
for _, entry in ipairs(entry_list) do
621-
if not M.should_display(entry[FIELD_NAME], bufnr) then
622-
goto continue
623-
end
624-
local cols = M.format_entry_cols(entry, column_defs, col_width, adapter)
625-
table.insert(line_table, cols)
626-
627-
local name = entry[FIELD_NAME]
628-
if seek_after_render == name then
629-
seek_after_render_found = true
630-
jump_idx = #line_table
631-
M.set_last_cursor(bufname, nil)
621+
if M.should_display(entry[FIELD_NAME], bufnr) then
622+
local cols = M.format_entry_cols(entry, column_defs, col_width, adapter)
623+
table.insert(line_table, cols)
624+
625+
local name = entry[FIELD_NAME]
626+
if seek_after_render == name then
627+
seek_after_render_found = true
628+
jump_idx = #line_table
629+
M.set_last_cursor(bufname, nil)
630+
end
632631
end
633-
::continue::
634632
end
635633

636634
local lines, highlights = util.render_table(line_table, col_width)

0 commit comments

Comments
 (0)