Skip to content

Commit

Permalink
fix: merge closing keymap handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shutils committed Feb 3, 2024
1 parent 5fa658b commit d63b91e
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 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 Expand Up @@ -407,15 +409,6 @@ M.edit_with_instructions = function(output_lines, bufnr, selection, ...)
end
end

-- close
for _, popup in ipairs({ input_window, output_window, settings_panel, instructions_input }) do
for _, mode in ipairs({ "n", "i" }) do
popup:map(mode, Config.options.edit_with_instructions.keymaps.close, function()
layout:hide()
end)
end
end

setup_and_mount(visual_lines, output_lines)
end

Expand Down

0 comments on commit d63b91e

Please sign in to comment.