fix: <C-\><C-\> toggles in ALL terminals, no Esc override needed
This commit is contained in:
parent
a26dc1a51a
commit
a169b3139c
|
|
@ -50,14 +50,14 @@ function M.open(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not terms[name] then
|
if not terms[name] then
|
||||||
local extra = {}
|
local cmd_saved = cmd
|
||||||
-- 只在普通 shell 绑 Esc → normal,Reasonix/lazygit 等 TUI 程序保留原生 <C-\><C-n>
|
terms[name] = require('toggleterm.terminal').Terminal:new(vim.tbl_extend('force', opts, {
|
||||||
if name == '__shell__' then
|
on_open = function(term)
|
||||||
extra.on_open = function(term)
|
vim.keymap.set('t', '<C-\\><C-\\>', function()
|
||||||
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { buffer = term.bufnr, noremap = true })
|
M.open(cmd_saved)
|
||||||
end
|
end, { buffer = term.bufnr, noremap = true })
|
||||||
end
|
end,
|
||||||
terms[name] = require('toggleterm.terminal').Terminal:new(vim.tbl_extend('force', opts, extra))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
terms[name]:toggle()
|
terms[name]:toggle()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue