akinsho / akinsho/toggleterm.nvim

[BUG] keymap focus / cursor desync with ToggleTermSendCurrentLine and ToggleTermSendVisualLines

オープン
#457 コメント 2 件 リアクション 0 件 担当者 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

When opening a terminal with:
- `ToggleTermSendCurrentLine`
- `ToggleTermSendVisualLines`

The terminal opens but:
- the cursor stays in the original window.
- the "focus" moves to the terminal window.

Such as if I use `hjkl` my cursor moves inside the original window, but if I use a keymap that does `"q!"` it closes the terminal window.

The above is what happens on the first iteration. On the second iteration, the terminal window opens, but the terminal buffer is inserted into my original "document" buffer window instead of its own.

---

Alternatively: when manually running `:q`

The first iteration goes as expected: the terminal opens, my cursor is still in the window, I type `:q`, my original window closes.

The second iteration however goes exactly as described above.

### Expected Behavior

Repeated uses of the commands should open new terminal windows when needed, and the terminal windows should always go to those buffers.

It seems that even though the cursor doesn't switch windows, the keymap capture does, this should not happen.

### Steps To Reproduce

Lazy lua module:

```lua
local function make_opts(_, opts)
local custom_opts = {
open_mapping = [[]],
}

return vim.tbl_deep_extend(
"force",
opts,
custom_opts
)
end

local function make_keymaps()
return {
{
"te",
"ToggleTermSendCurrentLine 8 ",
desc = "Execute current line in a terminal.",
},
{
"te",
"ToggleTermSendVisualLines 8 ",
mode = "v",
desc = "Execute selected lines in a terminal.",
},
}
end

return {
"akinsho/toggleterm.nvim",
lazy = false,
keys = make_keymaps(),
opts = make_opts,
}
```

Sample line to execute:

```md
ls
```

### Environment

- OS:
```sh
$ uname -a
Linux arch 6.4.1-arch2-1 #1 SMP PREEMPT_DYNAMIC Tue, 04 Jul 2023 08:39:40 +0000 x86_64 GNU/Linux
```
- neovim version:
```
:version
NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3
```
- Shell:
```sh
$ zsh --version
zsh 5.9 (x86_64-pc-linux-gnu)
```

### Anything else?

_No response_

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。