Skip to content

Commit

Permalink
chore: modify menu item only if it exists
Browse files Browse the repository at this point in the history
Co-authored-by: Micah Halter <micah@mehalter.com>
  • Loading branch information
azdanov and mehalter authored Oct 17, 2024
1 parent 1b3b8d3 commit 07886a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/content/docs/recipes/cmp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ return {
if truncated_label ~= label then vim_item.abbr = truncated_label .. astroui.get_icon "Ellipsis" end

-- truncate menu to maximum of 25% of the window
local menu = vim_item.menu or ""
local truncated_menu = vim.fn.strcharpart(menu, 0, math.floor(0.25 * vim.o.columns))
if truncated_menu ~= menu then vim_item.menu = truncated_menu .. astroui.get_icon "Ellipsis" end
if vim_item.menu then
local menu = vim_item.menu
local truncated_menu = vim.fn.strcharpart(menu, 0, math.floor(0.25 * vim.o.columns))
if truncated_menu ~= menu then vim_item.menu = truncated_menu .. astroui.get_icon "Ellipsis" end
end

return vim_item
end)
Expand Down

0 comments on commit 07886a9

Please sign in to comment.