From a7745445934c79bf5d49dee05bb81c604727a835 Mon Sep 17 00:00:00 2001 From: Alexey Radkov Date: Thu, 29 Aug 2024 20:23:57 +0400 Subject: [PATCH] fix: rendering shortcuts in long lines This patch - adds extra space before the shortcut label if padding.center is less than 1, - calculate correct position of shortcut when highlighting it by taking into account both padding.center and padding.left. --- lua/alpha.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/alpha.lua b/lua/alpha.lua index 22a4303..493b305 100644 --- a/lua/alpha.lua +++ b/lua/alpha.lua @@ -284,7 +284,7 @@ function layout_element.button(el, conf, state) end end if opts.align_shortcut == "right" then - val = { concat({ el.val, spaces(padding.center), opts.shortcut }) } + val = { concat({ el.val, spaces(math.max(padding.center,1)), opts.shortcut }) } else val = { concat({ opts.shortcut, el.val, spaces(padding.right) }) } end @@ -324,7 +324,7 @@ function layout_element.button(el, conf, state) hl = el.opts.hl_shortcut end if el.opts.align_shortcut == "right" then - hl = alpha.highlight(state, state.line, hl, #el.val + math.max(0,padding.center), el) + hl = alpha.highlight(state, state.line, hl, #el.val + math.max(padding.center,padding.left), el) else hl = alpha.highlight(state, state.line, hl, padding.left, el) end