Skip to content

Commit

Permalink
feat: align numbers in ui-select function
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekaboo authored and ibhagwan committed Feb 12, 2025
1 parent cfbd11f commit 755d9e6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/fzf-lua/providers/ui_select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ M.ui_select = function(items, ui_opts, on_choice)
title = "Mark `mymainmenu` as defined global."
} } ]]
local entries = {}
local num_width = math.ceil(math.log10(#items))
local num_format_str = "%" .. num_width .. "d"
for i, e in ipairs(items) do
table.insert(entries,
("%s. %s"):format(utils.ansi_codes.magenta(tostring(i)),
("%s. %s"):format(utils.ansi_codes.magenta(num_format_str:format(i)),
ui_opts.format_item and ui_opts.format_item(e) or tostring(e)))
end

Expand Down

0 comments on commit 755d9e6

Please sign in to comment.