Skip to content

Commit 8b4ccaf

Browse files
fix: remove esc keybinding (#240)
This MR removes the `<esc>` keybinding from the application for popups to avoid accidentally nuking existing changes. Addresses #239.
1 parent f55852f commit 8b4ccaf

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ require("gitlab").setup({
115115
},
116116
help = "g?", -- Opens a help popup for local keymaps when a relevant view is focused (popup, discussion panel, etc)
117117
popup = { -- The popup for comment creation, editing, and replying
118-
exit = "<Esc>",
119118
perform_action = "<leader>s", -- Once in normal mode, does action (like saving comment or editing description, etc)
120119
perform_linewise_action = "<leader>l", -- Once in normal mode, does the linewise action (see logs for this job, etc)
121120
width = "40%",

doc/gitlab.nvim.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ you call this function with no values the defaults will be used:
146146
},
147147
help = "g?", -- Opens a help popup for local keymaps when a relevant view is focused (popup, discussion panel, etc)
148148
popup = { -- The popup for comment creation, editing, and replying
149-
exit = "<Esc>",
150149
perform_action = "<leader>s", -- Once in normal mode, does action (like saving comment or editing description, etc)
151150
perform_linewise_action = "<leader>l", -- Once in normal mode, does the linewise action (see logs for this job, etc)
152151
width = "40%",

lua/gitlab/actions/create_mr.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,6 @@ M.add_title = function(mr)
196196
mr.title = value
197197
end,
198198
})
199-
input:map("n", "<Esc>", function()
200-
input:unmount()
201-
end, { noremap = true })
202-
203199
input:mount()
204200
end
205201

lua/gitlab/state.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ M.settings = {
2626
attachment_dir = "",
2727
help = "g?",
2828
popup = {
29-
exit = "<Esc>",
3029
perform_action = "<leader>s",
3130
perform_linewise_action = "<leader>l",
3231
width = "40%",
@@ -270,10 +269,6 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
270269
if opts == nil then
271270
opts = {}
272271
end
273-
vim.keymap.set("n", M.settings.popup.exit, function()
274-
exit(popup, opts)
275-
end, { buffer = popup.bufnr, desc = "Exit popup" })
276-
277272
if action ~= "Help" then -- Don't show help on the help popup
278273
vim.keymap.set("n", M.settings.help, function()
279274
local help = require("gitlab.actions.help")
@@ -304,6 +299,13 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
304299
linewise_action(text)
305300
end, { buffer = popup.bufnr, desc = "Perform linewise action" })
306301
end
302+
303+
vim.api.nvim_create_autocmd("BufUnload", {
304+
buffer = popup.bufnr,
305+
callback = function()
306+
exit(popup, opts)
307+
end,
308+
})
307309
end
308310

309311
-- Dependencies

0 commit comments

Comments
 (0)