Skip to content

Commit c15aefe

Browse files
authored
fix: respect autocomplete min_width (#86)
1 parent b4bbad1 commit c15aefe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lua/blink/cmp/windows/lib/render.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,22 @@ end
108108
--- @return number[]
109109
function renderer.get_max_lengths(components_list, min_width)
110110
local lengths = {}
111+
local first_fill = 1
112+
111113
for _, components in ipairs(components_list) do
112114
for i, component in ipairs(components) do
113115
local length = renderer.get_length(component)
114116
if not lengths[i] or lengths[i] < length then lengths[i] = length end
117+
if component.fill and first_fill == 1 then first_fill = i end
115118
end
116119
end
117120

118-
for i, length in ipairs(lengths) do
119-
if length < min_width then lengths[i] = min_width end
121+
for _, length in ipairs(lengths) do
122+
min_width = min_width - length
120123
end
121124

125+
if min_width > 0 then lengths[first_fill] = lengths[first_fill] + min_width end
126+
122127
return lengths
123128
end
124129

0 commit comments

Comments
 (0)