bug: opening a new tab with `:tabnew` from the dashboard does not restore old settings
Did you check docs and existing issues?
- [x] I have read all the snacks.nvim docs
- [x] I have updated the plugin to the latest version before submitting this issue
- [x] I have searched the existing issues of snacks.nvim
- [x] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
0.11.0
Operating system/version
Arch linux
Describe the bug
If I open a new tab page while on the dashboard the new tabpage will not have the correct settings applied. When running :tabnew it should see that I'm no longer in the dashboard buffer and re-enable tabline/statusline.
Steps To Reproduce
nvim -u repro.lua, start a new session (which opens the dashboard by default:tabnew, open a new tab page- See that statusline is still hidden
Expected Behavior
When opening a new tab, my settings should be reset to what I would expect them to be rather than still reflecting the settings which hide UI elements for the dashboard
Repro
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{ "folke/snacks.nvim", opts = { dashboard = {} } },
-- add any other plugins here
},
})
Are you sure it's not something with your configuration? I use LazyVim myself, but I've just tried a fresh LazyVim installation and it works like you would expect. Feel free to also test a new LazyVim installation yourself and then check if there are differences between the 2 configurations.
I also tried the minimal repro you linked and just put vim.opt.number = true before the call to lazy.minit and it shows the numbers when I open a new tabpage with :tabnew.
It appears number works. But on startup laststatus and showtabline are set to 0 when they shouldn't be until dashboard is closed. When opening a new tab like in the reproducing steps. laststatus and showtabline are not correctly set until the dashboard is then closed.
Recording: https://asciinema.org/a/g3yScFogg6eHTlP34tMp0FLHW
It appears it works after the initial dashboard is closed. If I don't have the dashboard start on startup and just open it. Then it works fine. So it's just a bug when the dashboard is started on startup.
Recording of the dashboard not enabled on startup and just starting it at runtime: https://asciinema.org/a/g2RhUd9w49fW0X4Aw9Suxd8Tj
Just a guess, but could you check if #1525 has anything to do with your problem? Other than that, I'm not really sure and sorry I can't be of further help.
PS: Plz disregard. That was specifically for snacks.picker and not dashboard, so it has to be something else.
I think it's because of this https://github.com/folke/snacks.nvim/blob/bc0630e43be5699bb94dadc302c0d21615421d93/lua/snacks/dashboard.lua#L1161-L1170. The values do indeed seem to only be restored on the User triggered event SnacksDashboardClosed. Maybe an additional autocmd should be created for other events?
Yup! That is the block of code that needs to be fixed 😄
We could add TabNew here, so that the Closed Snacks event will be triggered when opening a new tab as well, but from my testing since laststatus is global, it will reset on the new tab but will also remain reset when you switch back to the Dashboard tab later. Is this desired? I can't think of a way to separate the value in the 2 different tabs. What do you think?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This isn't stale
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Not stale
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
not stale
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Not stale
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Not stale