docs: Avante Chat History Selector Documentation and Commands (#1862)

This commit is contained in:
William Kang
2025-04-13 22:11:58 +09:00
committed by GitHub
parent f1abc57ebf
commit 0d26590389
3 changed files with 23 additions and 3 deletions

View File

@@ -52,8 +52,20 @@ function M.open(bufnr, cb)
local history = Path.history.load(vim.api.nvim_get_current_buf(), item.filename)
local Sidebar = require("avante.sidebar")
local content = Sidebar.render_history_content(history)
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, vim.split(content or "", "\n"))
vim.api.nvim_set_option_value("filetype", "markdown", { buf = self.state.bufnr })
local lines = vim.split(content or "", "\n")
-- Ensure the buffer exists and is valid before setting lines
if vim.api.nvim_buf_is_valid(self.state.bufnr) then
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines)
-- Set filetype after content is loaded
vim.api.nvim_set_option_value("filetype", "markdown", { buf = self.state.bufnr })
-- Ensure cursor is within bounds
vim.schedule(function()
if vim.api.nvim_buf_is_valid(self.state.bufnr) then
local row = math.min(vim.api.nvim_buf_line_count(self.state.bufnr), 1)
pcall(vim.api.nvim_win_set_cursor, self.state.winnr, { row, 0 })
end
end)
end
end,
}),
attach_mappings = function(prompt_bufnr, map)