Skip to content

Commit

Permalink
refactor(menu): pad last symbol in winbar menu
Browse files Browse the repository at this point in the history
So that the cursor will always on at least one symbol when inside a
winbar menu.
  • Loading branch information
Bekaboo committed Jan 16, 2025
1 parent 37c106e commit a272783
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lua/dropbar/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,16 @@ function dropbar_menu_t:fill_buf()
-- Pad lines with spaces to the width of the window
-- This is to make sure hl-DropBarMenuCurrentContext colors
-- the entire line
table.insert(
lines,
line
.. string.rep(
' ',
self._win_configs.width - vim.fn.strdisplaywidth(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 last_sym = entry.components[#entry.components]
last_sym.name = last_sym.name .. width_pad
line = line .. width_pad
end
table.insert(lines, line)
table.insert(hl_info, entry_hl_info)
if entry.virt_text then
table.insert(extmarks, i, entry.virt_text)
Expand Down

0 comments on commit a272783

Please sign in to comment.