From 8254df8b4ae0f14bcd19b4ae128db83a669a9afc Mon Sep 17 00:00:00 2001 From: bekaboo Date: Sat, 18 Jan 2025 22:24:05 -0500 Subject: [PATCH] refactor(menu): clean up `dropbar_menu_t:fill_buf()` --- lua/dropbar/menu.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lua/dropbar/menu.lua b/lua/dropbar/menu.lua index 31293875..355d296d 100644 --- a/lua/dropbar/menu.lua +++ b/lua/dropbar/menu.lua @@ -392,15 +392,13 @@ function dropbar_menu_t:fill_buf() -- the entire line -- Also pad the last symbol's name so that cursor is always -- on at least one symbol when inside the menu - local width_diff = self._win_configs.width - entry:displaywidth() - if width_diff > 0 then - local width_pad = string.rep(' ', width_diff) - local num_components = #entry.components - if num_components > 0 then - local last_sym = entry.components[num_components] - last_sym.name = last_sym.name .. width_pad + local n = self._win_configs.width - entry:displaywidth() + if n > 0 then + local last_sym = entry.components[#entry.components] + if last_sym then + last_sym.name = last_sym.name .. string.rep(' ', n) end - line = line .. width_pad + line = line .. string.rep(' ', n) end table.insert(lines, line) table.insert(hl_info, entry_hl_info)