From 8b0be086f8849c20cd2ae6b43da54cc675832e8a Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 12 Sep 2025 20:57:52 +0200 Subject: [PATCH] fix(ui): handle missing filename in chat block header 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. --- lua/CopilotChat/ui/chat.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/CopilotChat/ui/chat.lua b/lua/CopilotChat/ui/chat.lua index 51604d6a..3cf5efc7 100644 --- a/lua/CopilotChat/ui/chat.lua +++ b/lua/CopilotChat/ui/chat.lua @@ -48,7 +48,7 @@ local function match_block_header(header) if path then return type, path, tonumber(start_line) or 1, tonumber(end_line) or tonumber(start_line) or 1 elseif type then - return type, 'block' + return type, nil end end end @@ -801,7 +801,7 @@ function Chat:render() local header = block.header local filetype = header.filetype local filename = header.filename - local text = string.format('[%s] %s', filetype, filename) + local text = string.format('[%s] %s', filetype, filename or 'block') if header.start_line and header.end_line then text = text .. string.format(' lines %d-%d', header.start_line, header.end_line) end