Skip to content

Commit 559e754

Browse files
authored
fix(ui): improve help rendering and treesitter usage (#1411)
- Avoid starting treesitter if markdown parser already exists - Fix help message line positioning in chat - Render help virtual lines above for better visibility
1 parent 00d0fb3 commit 559e754

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lua/CopilotChat/ui/chat.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,9 @@ function Chat:create()
621621
self.spinner.bufnr = bufnr
622622

623623
vim.schedule(function()
624-
pcall(vim.treesitter.start, bufnr)
624+
if not vim.treesitter.get_parser(bufnr, 'markdown', {}) then
625+
pcall(vim.treesitter.start, bufnr)
626+
end
625627
end)
626628

627629
vim.api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave' }, {
@@ -906,7 +908,7 @@ function Chat:render()
906908
end
907909
msg = msg .. self.token_count .. '/' .. self.token_max_count .. ' tokens used'
908910
end
909-
self:show_help(msg, message.section.start_line - 1)
911+
self:show_help(msg, message.section.start_line)
910912
end
911913

912914
-- Auto fold non-assistant messages if enabled

lua/CopilotChat/ui/overlay.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ function Overlay:show_help(msg, pos)
143143
id = 1,
144144
hl_mode = 'combine',
145145
priority = 100,
146+
virt_lines_above = true,
146147
virt_lines = vim.tbl_map(function(t)
147148
return { { t, 'CopilotChatHelp' } }
148149
end, vim.split(msg, '\n')),

0 commit comments

Comments
 (0)