From 410a7360c1b8df2053ae7ba906ff74c9072e1505 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 19 Jun 2023 10:21:37 +0200 Subject: [PATCH] fix(ui): trailing space in button row. Fixes #884 --- lua/lazy/view/render.lua | 43 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 9021af2..19a6feb 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -113,30 +113,35 @@ end function M:title() self:nl():nl() - for _, mode in ipairs(ViewConfig.get_commands()) do - if mode.button then - local title = " " .. mode.name:sub(1, 1):upper() .. mode.name:sub(2) .. " (" .. mode.key .. ") " - if mode.name == "home" then - if self.view.state.mode == "home" then - title = " lazy.nvim " .. Config.options.ui.icons.lazy - else - title = " lazy.nvim (H) " - end - end + local modes = vim.tbl_filter(function(c) + return c.button + end, ViewConfig.get_commands()) - if self.view.state.mode == mode.name then - if mode.name == "home" then - self:append(title, "LazyH1", { wrap = true }) - else - self:append(title, "LazyButtonActive", { wrap = true }) - self:highlight({ ["%(.%)"] = "LazySpecial" }) - end + for c, mode in ipairs(modes) do + local title = " " .. mode.name:sub(1, 1):upper() .. mode.name:sub(2) .. " (" .. mode.key .. ") " + if mode.name == "home" then + if self.view.state.mode == "home" then + title = " lazy.nvim " .. Config.options.ui.icons.lazy else - self:append(title, "LazyButton", { wrap = true }) + title = " lazy.nvim (H) " + end + end + + if self.view.state.mode == mode.name then + if mode.name == "home" then + self:append(title, "LazyH1", { wrap = true }) + else + self:append(title, "LazyButtonActive", { wrap = true }) self:highlight({ ["%(.%)"] = "LazySpecial" }) end - self:append(" ") + else + self:append(title, "LazyButton", { wrap = true }) + self:highlight({ ["%(.%)"] = "LazySpecial" }) end + if c == #modes then + break + end + self:append(" ") end self:nl() if self.progress.done < self.progress.total then