Skip to content

Commit

Permalink
feat: add close keymap to edit windows (#172) (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
shutils authored Feb 5, 2024
1 parent 6e06912 commit 2476a64
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lua/chatgpt/code_edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,15 @@ M.edit_with_instructions = function(output_lines, bufnr, selection, ...)
end

-- close
for _, mode in ipairs({ "n", "i" }) do
instructions_input:map(mode, Config.options.edit_with_instructions.keymaps.close, function()
if vim.fn.mode() == "i" then
vim.api.nvim_command("stopinsert")
end
vim.cmd("q")
end, { noremap = true })
for _, popup in ipairs({ input_window, output_window, settings_panel, help_panel, instructions_input }) do
for _, mode in ipairs({ "n", "i" }) do
popup:map(mode, Config.options.edit_with_instructions.keymaps.close, function()
if vim.fn.mode() == "i" then
vim.api.nvim_command("stopinsert")
end
vim.cmd("q")
end, { noremap = true })
end
end

local function inTable(tbl, item)
Expand Down

0 comments on commit 2476a64

Please sign in to comment.