diff --git a/lua/cursor-agent/ui/term.lua b/lua/cursor-agent/ui/term.lua index 8253678..ef2c97e 100644 --- a/lua/cursor-agent/ui/term.lua +++ b/lua/cursor-agent/ui/term.lua @@ -74,6 +74,19 @@ function M.open_float_term(opts) M.close(win) end, { buffer = bufnr, nowait = true, silent = true }) + -- Add ESC key to close the floating window in normal, insert, and terminal modes + pcall(vim.keymap.set, 'n', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 'i', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 't', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + -- Jump to bottom and enter terminal-mode for immediate typing local ok_lines, line_count = pcall(vim.api.nvim_buf_line_count, bufnr) if ok_lines then pcall(vim.api.nvim_win_set_cursor, win, { line_count, 0 }) end @@ -118,6 +131,19 @@ function M.open_float_win_for_buf(bufnr, opts) M.close(win) end, { buffer = bufnr, nowait = true, silent = true }) + -- Add ESC key to close the floating window in normal, insert, and terminal modes + pcall(vim.keymap.set, 'n', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 'i', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + + pcall(vim.keymap.set, 't', '', function() + M.close(win) + end, { buffer = bufnr, nowait = true, silent = true }) + -- Jump to bottom and enter terminal-mode for immediate typing local ok_lines, line_count = pcall(vim.api.nvim_buf_line_count, bufnr) if ok_lines then pcall(vim.api.nvim_win_set_cursor, win, { line_count, 0 }) end