akinsho / akinsho/toggleterm.nvim

[BUG] Entering an existing terminal buffer does not trigger TermEnter event

未关闭
#621 6 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Lua
星标
5.6k
派生
206
PR 合并指标
30 天内没有已合并 PR

描述

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

Entering an already open terminal buffer does not trigger the TermEnter event. This leads to the issue, that my autocmd for TermEnter does not switch to insert mode when entering the terminal. TermEnter is now triggered after insert mode is activated in the terminal. Version 2.12.0 does not have this issue and works as expected.

### Expected Behavior

TermEnter event should be triggered when the cursor enters the buffer, not only when in insert mode in terminal.

### Steps To Reproduce

Use this autocmd and see if it gets triggered when entering the terminal buffer:

```lua
-- Auto insert mode when entering terminal
local augroup_term_insert = vim.api.nvim_create_augroup("Term-Insert", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "WinEnter", "TermOpen", "TermEnter" }, {
group = augroup_term_insert,
pattern = 'term://*',
callback = function(ev)
print("Auto-command triggered")
vim.cmd('startinsert')
end
})
```

Insert mode is only entered when the terminal is opened the fist time. Navigating out of the terminal buffer and navigating back should trigger the `TermEnter` event but does not. 2.12.0 does not have this issue

### Environment

```Markdown
- OS:
- neovim version:
- Shell:
```

### Anything else?

_No response_

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。