otavioschwanck / arrow.nvim

Bookmark your files, separated by project, and quickly navigate through them.
Other
454 stars 19 forks source link

Bug: not working with mini.sessions #9

Closed nuhakala closed 7 months ago

nuhakala commented 7 months ago

Hello, I just installed this plugin and it looks great. However, when I started it I got the following error.

E5108: Error executing lua: .../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:50: bad argument #1 to 'ipairs' (table expected, got number)
stack traceback:
        [C]: in function 'ipairs'
        .../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:50: in function 'format_file_names'
        .../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:300: in function <.../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:285>

After wondering a while, I realized that it opens the UI normally and works as expected if I open a file directly from command line and I do not load a session with mini.sessions.

I was doing a little bit of research myself, and it seems that the parameter to function format_file_names seems to be 0 in my case. And it seems to come from file persist.lua function load_cache_file, though I am not exactly sure.

otavioschwanck commented 7 months ago

Hello, I just installed this plugin and it looks great. However, when I started it I got the following error.

E5108: Error executing lua: .../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:50: bad argument #1 to 'ipairs' (table expected, got number)
stack traceback:
        [C]: in function 'ipairs'
        .../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:50: in function 'format_file_names'
        .../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:300: in function <.../.local/share/nvim/lazy/arrow.nvim/lua/arrow/ui.lua:285>

After wondering a while, I realized that it opens the UI normally and works as expected if I open a file directly from command line and I do not load a session with mini.sessions.

I was doing a little bit of research myself, and it seems that the parameter to function format_file_names seems to be 0 in my case. And it seems to come from file persist.lua function load_cache_file, though I am not exactly sure.

i think when you load the session, it is not loading the cache_file. Could you try to run:

:lua require("arrow.persist").load_cache_file() after loading the session?

EDIT:

i added the event to load cache file after loading session. Could you upgrade arrow and try again? https://github.com/otavioschwanck/arrow.nvim/commit/91078a5091ed03341d2b3f85aa2c6313d8e507ec

nuhakala commented 7 months ago

Yes, running that command helps, but the update did not fix it fully. If I read a session which already has arrow cache file created then it works correctly. If I load a session where I have not used arrow (no cache file exists), then it gives the same error. But I can fix the error by manually running that require command.

EDIT: I did some research on this, because the autocommand did not seem to trigger when changing session. When I changed the session manually by sourcing the session file :source path/to/session/file it did work, autocommand was triggered and arrow worked. Then I took a look at mini.sessions code here and it sources the file to restore session, so it should work also. Then I removed the silent prefix in that mini.sessions source command to see if it suppresses my debug prints, and after removing that, I saw my prints but also arrow started working??? No idea what is happening here since I am quite newbie in creating plugins, but looks like the culprit is mini.sessions.

So, the most convenient fix to this is to add require("arrow.persist").load_cache_file() to mini.sessions post-hook, or maybe try some other session manager.

I also assume that there is no further fix that arrow could do to fix this problem, if mini.sessions does not trigger the autocommand it should? If this is the case, could you mention this in readme, so others would know to fix their session managers.

Anyway, thanks for fast reply and awesome plugin!

otavioschwanck commented 7 months ago

Yes, running that command helps, but the update did not fix it fully. If I read a session which already has arrow cache file created then it works correctly. If I load a session where I have not used arrow (no cache file exists), then it gives the same error. But I can fix the error by manually running that require command.

EDIT: I did some research on this, because the autocommand did not seem to trigger when changing session. When I changed the session manually by sourcing the session file :source path/to/session/file it did work, autocommand was triggered and arrow worked. Then I took a look at mini.sessions code here and it sources the file to restore session, so it should work also. Then I removed the silent prefix in that mini.sessions source command to see if it suppresses my debug prints, and after removing that, I saw my prints but also arrow started working??? No idea what is happening here since I am quite newbie in creating plugins, but looks like the culprit is mini.sessions.

So, the most convenient fix to this is to add require("arrow.persist").load_cache_file() to mini.sessions post-hook, or maybe try some other session manager.

I also assume that there is no further fix that arrow could do to fix this problem, if mini.sessions does not trigger the autocommand it should? If this is the case, could you mention this in readme, so others would know to fix their session managers.

Anyway, thanks for fast reply and awesome plugin!

I will add to the readme, thanks!

EDIT:

on https://github.com/folke/persistence.nvim, arrow works correctly.