Restore chat history

This commit is contained in:
Jonas Widen 2025-03-16 19:24:58 +01:00
parent 27c22bed6e
commit c3346f2274

@ -111,13 +111,16 @@ function M.create_window()
end
end
function M.update_content(content, is_new_chat)
function M.update_content(content, is_new_chat, is_thinking)
vim.api.nvim_buf_set_option(state.bufnr, 'modifiable', true)
local lines = vim.split(content, "\n")
if #state.conversation_history > 1 then -- Check if there's more than one message
-- Add separator before new content
-- Only add separator if:
-- 1. Not the first message
-- 2. Not a thinking message
-- 3. There's existing content in the buffer
if not is_thinking and not is_new_chat and vim.api.nvim_buf_line_count(state.bufnr) > 0 then
local separator = "━━━━━━━━━━━━━━━━━━━━━━━━━━"
table.insert(lines, 1, separator)
end