fix: send the latest file content each time (#1879)

This commit is contained in:
yetone
2025-04-15 20:16:13 +08:00
committed by GitHub
parent fdcfda7437
commit 1fdb1a7b84
9 changed files with 78 additions and 35 deletions

View File

@@ -184,10 +184,26 @@ function M.generate_prompts(opts)
local system_info = Utils.get_system_info()
local selected_files = opts.selected_files or {}
if opts.selected_filepaths then
for _, filepath in ipairs(opts.selected_filepaths) do
local lines, error = Utils.read_file_from_buf_or_disk(filepath)
lines = lines or {}
local filetype = Utils.get_filetype(filepath)
if error ~= nil then
Utils.error("error reading file: " .. error)
else
local content = table.concat(lines, "\n")
table.insert(selected_files, { path = filepath, content = content, file_type = filetype })
end
end
end
local template_opts = {
ask = opts.ask, -- TODO: add mode without ask instruction
code_lang = opts.code_lang,
selected_files = opts.selected_files,
selected_files = selected_files,
selected_code = opts.selected_code,
recently_viewed_files = opts.recently_viewed_files,
project_context = opts.project_context,