fix: add compatibility for Lua 5.1 (#456)
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 <julianonline+github@posteo.de>
This commit is contained in:
parent
fcca212c2e
commit
b39a78959f
2 changed files with 109 additions and 107 deletions
|
|
@ -192,7 +192,11 @@ M.parse = function(bufnr)
|
||||||
seen_names[name] = true
|
seen_names[name] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
|
-- hack to be compatible with Lua 5.1
|
||||||
|
-- use return instead of goto
|
||||||
|
(function()
|
||||||
if line:match("^/%d+") then
|
if line:match("^/%d+") then
|
||||||
-- Parse the line for an existing entry
|
-- Parse the line for an existing entry
|
||||||
local result, err = M.parse_line(adapter, line, column_defs)
|
local result, err = M.parse_line(adapter, line, column_defs)
|
||||||
|
|
@ -203,10 +207,10 @@ M.parse = function(bufnr)
|
||||||
end_lnum = i,
|
end_lnum = i,
|
||||||
col = 0,
|
col = 0,
|
||||||
})
|
})
|
||||||
goto continue
|
return
|
||||||
elseif result.data.id == 0 then
|
elseif result.data.id == 0 then
|
||||||
-- Ignore entries with ID 0 (typically the "../" entry)
|
-- Ignore entries with ID 0 (typically the "../" entry)
|
||||||
goto continue
|
return
|
||||||
end
|
end
|
||||||
local parsed_entry = result.data
|
local parsed_entry = result.data
|
||||||
local entry = result.entry
|
local entry = result.entry
|
||||||
|
|
@ -226,7 +230,7 @@ M.parse = function(bufnr)
|
||||||
end_lnum = i,
|
end_lnum = i,
|
||||||
col = 0,
|
col = 0,
|
||||||
})
|
})
|
||||||
goto continue
|
return
|
||||||
end
|
end
|
||||||
assert(entry)
|
assert(entry)
|
||||||
|
|
||||||
|
|
@ -281,7 +285,7 @@ M.parse = function(bufnr)
|
||||||
end_lnum = i,
|
end_lnum = i,
|
||||||
col = 0,
|
col = 0,
|
||||||
})
|
})
|
||||||
goto continue
|
return
|
||||||
end
|
end
|
||||||
if name ~= "" then
|
if name ~= "" then
|
||||||
local link_pieces = vim.split(name, " -> ", { plain = true })
|
local link_pieces = vim.split(name, " -> ", { plain = true })
|
||||||
|
|
@ -300,7 +304,7 @@ M.parse = function(bufnr)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
::continue::
|
end)()
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, child_id in pairs(original_entries) do
|
for name, child_id in pairs(original_entries) do
|
||||||
|
|
|
||||||
|
|
@ -626,9 +626,7 @@ local function render_buffer(bufnr, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, entry in ipairs(entry_list) do
|
for _, entry in ipairs(entry_list) do
|
||||||
if not M.should_display(entry[FIELD_NAME], bufnr) then
|
if M.should_display(entry[FIELD_NAME], bufnr) then
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
local cols = M.format_entry_cols(entry, column_defs, col_width, adapter)
|
local cols = M.format_entry_cols(entry, column_defs, col_width, adapter)
|
||||||
table.insert(line_table, cols)
|
table.insert(line_table, cols)
|
||||||
|
|
||||||
|
|
@ -638,7 +636,7 @@ local function render_buffer(bufnr, opts)
|
||||||
jump_idx = #line_table
|
jump_idx = #line_table
|
||||||
M.set_last_cursor(bufname, nil)
|
M.set_last_cursor(bufname, nil)
|
||||||
end
|
end
|
||||||
::continue::
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local lines, highlights = util.render_table(line_table, col_width)
|
local lines, highlights = util.render_table(line_table, col_width)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue