snacks.nvim icon indicating copy to clipboard operation
snacks.nvim copied to clipboard

bug: opening a new tab with `:tabnew` from the dashboard does not restore old settings

Open mehalter opened this issue 8 months ago • 9 comments

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

  1. nvim -u repro.lua, start a new session (which opens the dashboard by default
  2. :tabnew, open a new tab page
  3. 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
  },
})

mehalter avatar Apr 21 '25 12:04 mehalter

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.

dpetka2001 avatar Apr 21 '25 15:04 dpetka2001

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

mehalter avatar Apr 21 '25 16:04 mehalter

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

mehalter avatar Apr 21 '25 16:04 mehalter

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.

dpetka2001 avatar Apr 21 '25 16:04 dpetka2001

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?

dpetka2001 avatar Apr 21 '25 16:04 dpetka2001

Yup! That is the block of code that needs to be fixed 😄

mehalter avatar Apr 21 '25 17:04 mehalter

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?

dpetka2001 avatar Apr 21 '25 17:04 dpetka2001

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.

github-actions[bot] avatar May 22 '25 02:05 github-actions[bot]

This isn't stale

mehalter avatar May 22 '25 11:05 mehalter

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.

github-actions[bot] avatar Jun 22 '25 02:06 github-actions[bot]

Not stale

mehalter avatar Jun 22 '25 02:06 mehalter

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.

github-actions[bot] avatar Jul 30 '25 02:07 github-actions[bot]

not stale

mehalter avatar Jul 30 '25 02:07 mehalter

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.

github-actions[bot] avatar Sep 01 '25 02:09 github-actions[bot]

Not stale

mehalter avatar Sep 01 '25 02:09 mehalter

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.

github-actions[bot] avatar Oct 03 '25 02:10 github-actions[bot]

Not stale

mehalter avatar Oct 03 '25 02:10 mehalter