Skip to content

Commit 38aa043

Browse files
committed
fix(formatter): extend user message border when file parts precede text
Extend end_line passed to add_vertical_border when a message contains file parts followed by non-synthetic text so extmarks are included and the vertical border doesn't clip the content.
1 parent 626130f commit 38aa043

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

lua/opencode/ui/formatter.lua

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,26 @@ function M._format_user_prompt(output, text, message)
355355
mention.highlight_mentions_in_output(output, text, mentions, start_line)
356356
end
357357

358-
M.add_vertical_border(output, start_line, end_line, 'OpencodeMessageRoleUser', -3)
358+
local end_line_extmark_offset = 0
359+
if message and message.parts then
360+
local has_file_parts = false
361+
local last_content_idx = 0
362+
local text_idx = 0
363+
for i, part in ipairs(message.parts) do
364+
if part.type == 'file' then
365+
has_file_parts = true
366+
last_content_idx = i
367+
elseif part.type == 'text' and not part.synthetic then
368+
text_idx = i
369+
last_content_idx = i
370+
end
371+
end
372+
if has_file_parts and text_idx > 0 and text_idx == last_content_idx then
373+
end_line_extmark_offset = 1
374+
end
375+
end
376+
377+
M.add_vertical_border(output, start_line, end_line + end_line_extmark_offset, 'OpencodeMessageRoleUser', -3)
359378
end
360379

361380
---@param output Output Output object to write to

0 commit comments

Comments
 (0)