If you scroll up in terminal-normal mode and then call :tabnew %, a regular terminal keeps the same cursor position in the new tab. However a toggleterm does not.
Several plugins spawn new tabs from buffers such as :ZoomWinTabToggle from https://github.com/troydm/zoomwintab.vim. (To be specific, that plugin uses :tab sb bufnr() but it's the same issue)
Expected Behavior
Creating a new tab from a toggleterm buffer continues to use the same cursor position.
Steps To Reproduce
Using this reproduction file
Click to expand
```lua
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{'akinsho/toggleterm.nvim', version = "*", config = true},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
```
Save the lua above to /tmp/minimal_reproduction.lua
Load neovim -u /tmp/minimal_reproduction.lua
Call :ToggleTerm
call cat /tmp/some_large_file.txt (A file with a lot of text in it)
Press <C-\>C-n> to escape TERMINAL mode back into NORMAL mode in the same terminal buffer
Call :tabnew %
The created tab + toggleterm buffer will have its position at the bottom of the buffer, rather than wherever you last left it.
There's also a second issue where calling :set showtabline=0 before calling :tabclose will cause the original toggleterm buffer's cursor position to be reset. But with this bug in play, it's hard to tell if that's a separate issue or a different symptom to the same issue as this.
Is there an existing issue for this?
Current Behavior
If you scroll up in terminal-normal mode and then call
:tabnew %
, a regular terminal keeps the same cursor position in the new tab. However a toggleterm does not.Several plugins spawn new tabs from buffers such as
:ZoomWinTabToggle
from https://github.com/troydm/zoomwintab.vim. (To be specific, that plugin uses:tab sb bufnr()
but it's the same issue)Expected Behavior
Creating a new tab from a toggleterm buffer continues to use the same cursor position.
Steps To Reproduce
Using this reproduction file
Click to expand
```lua -- DO NOT change the paths and don't remove the colorscheme local root = vim.fn.fnamemodify("./.repro", ":p") -- set stdpaths to use .repro for _, name in ipairs({ "config", "data", "state", "cache" }) do vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name end -- bootstrap lazy local lazypath = root .. "/plugins/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "--single-branch", "https://github.com/folke/lazy.nvim.git", lazypath, }) end vim.opt.runtimepath:prepend(lazypath) -- install plugins local plugins = { {'akinsho/toggleterm.nvim', version = "*", config = true}, } require("lazy").setup(plugins, { root = root .. "/plugins", }) ```/tmp/minimal_reproduction.lua
:ToggleTerm
cat /tmp/some_large_file.txt
(A file with a lot of text in it)<C-\>C-n>
to escapeTERMINAL
mode back intoNORMAL
mode in the same terminal buffer:tabnew %
The created tab + toggleterm buffer will have its position at the bottom of the buffer, rather than wherever you last left it.
See this video for a demonstration
https://github.com/akinsho/toggleterm.nvim/assets/10103049/da883d1a-fbdf-47b2-99ec-eebe299c023f
There's also a second issue where calling
:set showtabline=0
before calling:tabclose
will cause the original toggleterm buffer's cursor position to be reset. But with this bug in play, it's hard to tell if that's a separate issue or a different symptom to the same issue as this.Environment
Anything else?
No response