Minor fix

This commit is contained in:
Jonas Widen 2025-03-16 17:58:46 +01:00
parent fa6f653e3f
commit c81f36fa17

View File

@ -141,12 +141,16 @@ local function update_chat_window(new_content)
vim.api.nvim_buf_set_option(chat_bufnr, 'modifiable', false) vim.api.nvim_buf_set_option(chat_bufnr, 'modifiable', false)
end end
-- Scroll to bottom -- Find the start of the current query (last line count - number of lines in new_content + 1)
local line_count = vim.api.nvim_buf_line_count(chat_bufnr) local line_count = vim.api.nvim_buf_line_count(chat_bufnr)
vim.api.nvim_win_set_cursor(chat_winnr, {line_count, 0}) local new_content_lines = #vim.split(new_content, "\n")
local query_start_line = line_count - new_content_lines + 1
-- Ensure the last line is visible
vim.api.nvim_command('normal! zz') -- Set cursor to the start of current query
vim.api.nvim_win_set_cursor(chat_winnr, {query_start_line, 0})
-- Scroll the window to show the query at the top
vim.cmd('normal! zt')
-- Return focus to the previous window -- Return focus to the previous window
vim.cmd('wincmd p') vim.cmd('wincmd p')