Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup: always at least insert something, also more instruction
  • Loading branch information
tjdevries committed Mar 12, 2024
commit d000f38253db0ec02e0b1410daeb1c998f055cd2
4 changes: 1 addition & 3 deletions lua/sg/cody/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,16 @@ commands.do_task = function(bufnr, start_line, end_line, message)
local formatted = util.format_code(bufnr, selection)

local prompt = message
prompt = prompt .. "\nReply only with code, nothing else\n"
prompt = prompt .. "\nReply only with code, nothing else. Enclose it in a markdown style block.\n"
prompt = prompt .. table.concat(formatted, "\n")

local rpc = require "sg.cody.rpc"
rpc.request("chat/new", nil, function(err, id)
print("CHAT NEW:", err, id)
if err then
vim.notify(err)
return
end

vim.notify(string.format("Chat ID: %s", id))
require("sg.cody.tasks").init {
id = id,
bufnr = bufnr,
Expand Down
4 changes: 4 additions & 0 deletions lua/sg/cody/tasks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ CodyTask.init = function(opts)
end
end

if #to_insert == 0 then
to_insert = lines
end

vim.api.nvim_buf_set_lines(opts.bufnr, opts.start_row, opts.end_row, false, to_insert)

-- Attempt to indent this code
Expand Down