Skip to content

Commit

Permalink
fix: use vim.ui.input in CodyTask
Browse files Browse the repository at this point in the history
Closes #219
  • Loading branch information
tjdevries committed May 25, 2024
1 parent 92a9f5f commit 8bdd4d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions lua/sg/cody/plugin/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,20 @@ commands.CodyToggle = {
commands.CodyTask = {
function(command)
local bufnr = vim.api.nvim_get_current_buf()
cody_commands.do_task(bufnr, command.line1 - 1, command.line2, command.args)

if command.args == "" then
vim.ui.input({ prompt = "Cody Task: " }, function(input)
if not input or input == "" then
return
end

cody_commands.do_task(bufnr, command.line1 - 1, command.line2, input)
end)
else
cody_commands.do_task(bufnr, command.line1 - 1, command.line2, command.args)
end
end,
{ range = 2, nargs = 1 },
{ range = 2, nargs = "*" },
}

---@command :CodyRestart [[
Expand Down
2 changes: 1 addition & 1 deletion lua/sg/cody/tasks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CodyTask.init = function(opts)

local bufnr = task.windows.history_bufnr
vim.keymap.set("n", "<CR>", function()
local text = task.transcript:last_message():text()
local text = task.transcript:last_message():text() or ""
local lines = vim.split(vim.trim(text), "\n")
local to_insert = {}

Expand Down

0 comments on commit 8bdd4d1

Please sign in to comment.