Skip to content

Commit d73dfcb

Browse files
authored
fix(window): clamp highlights to prevent overflow beyond text bounds (#2049)
This prevents highlights from overflowing into next columns, ensuring that highlight ranges stay inside their text.
1 parent 7378f82 commit d73dfcb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/blink/cmp/completion/windows/render/column.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ function column:get_line_highlights(line_idx)
103103
table.insert(highlights, { offset, offset + #text, group = column_highlights })
104104
elseif type(column_highlights) == 'table' then
105105
for _, highlight in ipairs(column_highlights) do
106+
local start_col = offset + (highlight[1] or 0)
107+
local end_col = offset + (highlight[2] or #text)
108+
106109
table.insert(highlights, {
107-
offset + (highlight[1] or 0),
108-
offset + (highlight[2] or #text),
110+
math.min(math.max(start_col, offset), offset + #text),
111+
math.min(math.max(end_col, offset), offset + #text),
109112
group = highlight.group,
110113
params = highlight.params,
111114
priority = highlight.priority,

0 commit comments

Comments
 (0)