romgrk / barbar.nvim

The neovim tabline plugin.
2.16k stars 81 forks source link

[Buf] Session pin doesn't always be saved with persistence #467

Closed otavioschwanck closed 1 year ago

otavioschwanck commented 1 year ago

Description

Sometime the buffer pins are not being saved. Not occurs everytime, it happens while using from some time. More the buffer count, more the chance of failing.

If i delete the session file it stop messing for a while.

My persistence config:

{
    "folke/persistence.nvim",
    event = "BufReadPre",
    config = function ()
      require("persistence").setup({
        dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
        options = {'buffers', 'curdir', 'globals', 'tabpages', 'winsize'},
        pre_save = function() vim.api.nvim_exec_autocmds('User', { pattern = 'SessionSavePre' }) end,
      })

      require("mood-scripts.auto-save-session").setup()
    end
  }
  local M = {}

-- at mood-scripts.auto-save-session
function M.save_session()
  local file_type = vim.bo.filetype

  if file_type ~= 'alpha' then
    require('persistence').save()
  end
end

function M.setup()
  vim.cmd([[
    call timer_start(1000 * 15, { id -> execute("lua require('mood-scripts.auto-save-session').save_session()") }, { 'repeat': -1 })
  ]])
end

return M

session save

Session files generated from the gif:

First loan session: https://pasteio.com/xfWhLzAfiV6e

After i pin a buffer (lsp.lua) and call vim.api.nvim_exec_autocmds('User', { pattern = 'SessionSavePre' }) manually: https://pasteio.com/xXnoZUpx8yQt

After i close the neovim (the variable is pinned = true here): https://pasteio.com/x46HW0ih4ZVU

(if i reopen after this last close, the buffer will not be persisted for some reason

If i close the rest of the files, it will persisted normally for some reason.

I have a autosave (each 15s) for the session, i close and open all the time. i think is some point the session save is getting messed for some reason

EDIT: Just deleting the session and saving the same buffers make it works... but will break after a while. EDIT 2: Already broke hahah

init.vim: https://github.com/otavioschwanck/mood-nvim

Iron-E commented 1 year ago

If you can post an example of a session file that isn't working for you, that will help!

Make sure to strip personal information out.

otavioschwanck commented 1 year ago

If you can post an example of a session file that isn't working for you, that will help!

Make sure to strip personal information out.

the sessions that i posted are the ones that isn't working

Iron-E commented 1 year ago

Oops. That was a little stupid of me šŸ˜…

otavioschwanck commented 1 year ago

Oops. That was a little stupid of me šŸ˜…

Just to add here: Seems like the number of files open interferes on when the pins will be save or not.

Iron-E commented 1 year ago

I can reproduce using your provided session files. Something is definitely going on here.

Iron-E commented 1 year ago

Okay, I figured it out. The problem is this:

What to do about it? That's what I have to figure out next.