Skip to content

Commit 07886a9

Browse files
azdanovmehalter
andauthored
chore: modify menu item only if it exists
Co-authored-by: Micah Halter <[email protected]>
1 parent 1b3b8d3 commit 07886a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/content/docs/recipes/cmp.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ return {
164164
if truncated_label ~= label then vim_item.abbr = truncated_label .. astroui.get_icon "Ellipsis" end
165165

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

171173
return vim_item
172174
end)

0 commit comments

Comments
 (0)