Skip to content

Commit

Permalink
use only the specified field's width for the window width
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Jan 6, 2025
1 parent 4c1ca82 commit 28ab7f7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/cmp/view/custom_entries_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,17 @@ custom_entries_view.open = function(self, offset, entries)
self.column_width = { abbr = 0, kind = 0, menu = 0 }

local entries_buf = self.entries_win:get_buffer()
local fields = config.get().formatting.fields
local lines = {}
local dedup = {}
local preselect_index = 0
for _, e in ipairs(entries) do
local view = e:get_view(offset, entries_buf)
if view.dup == 1 or not dedup[e.completion_item.label] then
dedup[e.completion_item.label] = true
self.column_width.abbr = math.max(self.column_width.abbr, view.abbr.width)
self.column_width.kind = math.max(self.column_width.kind, view.kind.width)
self.column_width.menu = math.max(self.column_width.menu, view.menu.width)
for _, field in ipairs(fields) do
self.column_width[field] = math.max(self.column_width[field], view[field].width)
end
table.insert(self.entries, e)
table.insert(lines, ' ')
if preselect_index == 0 and e.completion_item.preselect then
Expand Down

0 comments on commit 28ab7f7

Please sign in to comment.