From 86709a51baa71201891a50897c85178d81358d6f Mon Sep 17 00:00:00 2001 From: Jonas Widen Date: Sun, 16 Mar 2025 19:19:34 +0100 Subject: [PATCH] Restore chat history --- lua/gemini/chat.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/gemini/chat.lua b/lua/gemini/chat.lua index 73da27c..6ad3dbd 100644 --- a/lua/gemini/chat.lua +++ b/lua/gemini/chat.lua @@ -115,7 +115,20 @@ function M.update_content(content, is_new_chat) vim.api.nvim_buf_set_option(state.bufnr, 'modifiable', true) if is_new_chat then - vim.api.nvim_buf_set_lines(state.bufnr, 0, -1, false, vim.split(content, "\n")) + -- Don't clear existing content, append to it + local lines = vim.split(content, "\n") + if #state.conversation_history > 0 then + -- Add separator before new content + local separator = "━━━━━━━━━━━━━━━━━━━━━━━━━━" + table.insert(lines, 1, separator) + -- Get current buffer content + local current_lines = vim.api.nvim_buf_get_lines(state.bufnr, 0, -1, false) + -- Combine existing content with new content + for i = #current_lines, 1, -1 do + table.insert(lines, 1, current_lines[i]) + end + end + vim.api.nvim_buf_set_lines(state.bufnr, 0, -1, false, lines) else local separator = "━━━━━━━━━━━━━━━━━━━━━━━━━━" vim.api.nvim_buf_set_lines(state.bufnr, -1, -1, false, {separator})