diff --git a/lua/neo-tree/sources/common/container.lua b/lua/neo-tree/sources/common/container.lua index ac836702a..ce7520d5a 100644 --- a/lua/neo-tree/sources/common/container.lua +++ b/lua/neo-tree/sources/common/container.lua @@ -71,22 +71,23 @@ local render_content = function(config, node, state, context) local rendered_width = 0 for _, item in ipairs(items) do - if item.enabled == false then - goto continue - end - local required_width = item.required_width or 0 - if required_width > window_width then - goto continue - end - local rendered_item = renderer.render_component(item, node, state, context.available_width) - if rendered_item then - local align = item.align or "left" - should_pad[align] = add_padding(rendered_item, should_pad[align]) + repeat -- doing this instead of goto continue for lua 5.1 compat + if item.enabled == false then + break + end + local required_width = item.required_width or 0 + if required_width > window_width then + break + end + local rendered_item = renderer.render_component(item, node, state, context.available_width) + if rendered_item then + local align = item.align or "left" + should_pad[align] = add_padding(rendered_item, should_pad[align]) - vim.list_extend(zindex_rendered[align], rendered_item) - rendered_width = rendered_width + calc_rendered_width(rendered_item) - end - ::continue:: + vim.list_extend(zindex_rendered[align], rendered_item) + rendered_width = rendered_width + calc_rendered_width(rendered_item) + end + until true end max_width = math.max(max_width, rendered_width) diff --git a/lua/neo-tree/ui/renderer.lua b/lua/neo-tree/ui/renderer.lua index 717b2afc8..fc95ad310 100644 --- a/lua/neo-tree/ui/renderer.lua +++ b/lua/neo-tree/ui/renderer.lua @@ -426,31 +426,32 @@ local prepare_node = function(item, state) local should_pad = false for _, component in ipairs(renderer) do - if component.enabled == false then - goto continue - end - local component_data, component_wanted_width = - M.render_component(component, item, state, remaining_cols - (should_pad and 1 or 0)) - local actual_width = 0 - if component_data then - for _, data in ipairs(component_data) do - if data.text then - local padding = "" - if should_pad and #data.text and data.text:sub(1, 1) ~= " " and not data.no_padding then - padding = " " - end - data.text = padding .. data.text - should_pad = data.text:sub(#data.text) ~= " " and not data.no_next_padding + repeat + if component.enabled == false then + break + end + local component_data, component_wanted_width = + M.render_component(component, item, state, remaining_cols - (should_pad and 1 or 0)) + local actual_width = 0 + if component_data then + for _, data in ipairs(component_data) do + if data.text then + local padding = "" + if should_pad and #data.text and data.text:sub(1, 1) ~= " " and not data.no_padding then + padding = " " + end + data.text = padding .. data.text + should_pad = data.text:sub(#data.text) ~= " " and not data.no_next_padding - actual_width = actual_width + vim.api.nvim_strwidth(data.text) - line:append(data.text, data.highlight) - remaining_cols = remaining_cols - vim.fn.strchars(data.text) + actual_width = actual_width + vim.api.nvim_strwidth(data.text) + line:append(data.text, data.highlight) + remaining_cols = remaining_cols - vim.fn.strchars(data.text) + end end end - end - component_wanted_width = component_wanted_width or actual_width - wanted_width = wanted_width + component_wanted_width - ::continue:: + component_wanted_width = component_wanted_width or actual_width + wanted_width = wanted_width + component_wanted_width + until true end line.wanted_width = wanted_width