Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lua/cursor-agent/ui/term.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<Esc>', function()
M.close(win)
end, { buffer = bufnr, nowait = true, silent = true })

pcall(vim.keymap.set, 'i', '<Esc>', function()
M.close(win)
end, { buffer = bufnr, nowait = true, silent = true })

pcall(vim.keymap.set, 't', '<Esc>', 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
Expand Down Expand Up @@ -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', '<Esc>', function()
M.close(win)
end, { buffer = bufnr, nowait = true, silent = true })

pcall(vim.keymap.set, 'i', '<Esc>', function()
M.close(win)
end, { buffer = bufnr, nowait = true, silent = true })

pcall(vim.keymap.set, 't', '<Esc>', 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
Expand Down