Skip to content

Commit 5c3a558

Browse files
authored
fix(ui): handle missing filename in chat block header (#1406)
Previously, chat blocks without a filename would display 'block' as the filename. This change updates the logic to use nil for missing filenames and ensures the UI displays 'block' only when filename is not present. This improves clarity and consistency in chat block rendering.
1 parent 9fdf895 commit 5c3a558

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lua/CopilotChat/ui/chat.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ local function match_block_header(header)
4848
if path then
4949
return type, path, tonumber(start_line) or 1, tonumber(end_line) or tonumber(start_line) or 1
5050
elseif type then
51-
return type, 'block'
51+
return type, nil
5252
end
5353
end
5454
end
@@ -801,7 +801,7 @@ function Chat:render()
801801
local header = block.header
802802
local filetype = header.filetype
803803
local filename = header.filename
804-
local text = string.format('[%s] %s', filetype, filename)
804+
local text = string.format('[%s] %s', filetype, filename or 'block')
805805
if header.start_line and header.end_line then
806806
text = text .. string.format(' lines %d-%d', header.start_line, header.end_line)
807807
end

0 commit comments

Comments
 (0)