Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the session is restored, yazi will also be opened automatically #440

Closed
mingo99 opened this issue Sep 7, 2024 · 14 comments · Fixed by #442
Closed

When the session is restored, yazi will also be opened automatically #440

mingo99 opened this issue Sep 7, 2024 · 14 comments · Fixed by #442

Comments

@mingo99
Copy link

mingo99 commented Sep 7, 2024

Version

  • Neovim: 0.10.1
  • LazyVim: latest
  • Yazi: 0.3.3

Description

After opening the folder to restore the session(there are already files open), Yazi opens automatically.
image

Steps To Reproduce

Enter the folder where the session has been saved, enter nvim, and then reload the session.

Expected Behavior

Like neo-tree, when the session already has files open, don't open yazi.

My config

  {
    "mikavilpas/yazi.nvim",
    event = "VeryLazy",
    opts = {
      open_for_directories = true,
    },
  },
  {
    "nvim-neo-tree/neo-tree.nvim",
    opts = {
      filesystem = {
        hijack_netrw_behavior = "disabled",
      },
    },
  },
@mikavilpas
Copy link
Owner

I'm not familiar with this feature. I use lazyvim and it saves the session automatically (I think). I can reload the session with s on the start screen.

How do you reload your session exactly?

@mingo99
Copy link
Author

mingo99 commented Sep 7, 2024

Just like you.

@qeisar
Copy link

qeisar commented Sep 7, 2024

I am having something that might be similar or related. When I navigate with yazi.nvim then quit with q while hovering on a directory, then try to resume with <C-up> yazi-nvim enters that directory.

@mingo99
Copy link
Author

mingo99 commented Sep 8, 2024

I am having something that might be similar or related. When I navigate with yazi.nvim then quit with q while hovering on a directory, then try to resume with <C-up> yazi-nvim enters that directory.

Uh, I don't get it.

@mikavilpas
Copy link
Owner

I am having something that might be similar or related. When I navigate with yazi.nvim then quit with q while hovering on a directory, then try to resume with <C-up> yazi-nvim enters that directory.

This happened to me too, and I opened this issue to investigate it sxyazi/yazi#1610. Right now yazi does not seem to have a way to open and hover a directory.

@mingo99
Copy link
Author

mingo99 commented Sep 8, 2024

I am having something that might be similar or related. When I navigate with yazi.nvim then quit with q while hovering on a directory, then try to resume with <C-up> yazi-nvim enters that directory.

Yeah, I understand what you mean, and I tried it. It's the same for me, but I think it's different from my issue. My issue seems more like Yazi cwd was executed directly after loading the session. BTW, maybe I missed an important detail, the situation I mentioned happens after Yazi has been opened in Neovim.

@mikavilpas
Copy link
Owner

Yeah I think that case is different. Is there some way I can reproduce this?

@mingo99
Copy link
Author

mingo99 commented Sep 8, 2024

Yeah, You can try it this way (with config above).

cd ~/.config/yazi  # Any dir
nvim .
# Yazi open automatically and select any file to open, then exit neovim (<leader>qq in Lazyvim).
nvim

Then you'll see it as shown in the screenshot above.

@mikavilpas
Copy link
Owner

When I open nvim the second time, it does not open any files - it shows the lazyvim default startup screen. Do you have some setting or other plugin that might do something here?

@mingo99
Copy link
Author

mingo99 commented Sep 8, 2024 via email

@mikavilpas
Copy link
Owner

Oh now I can reproduce it. Thanks! I'll try to figure out a good way to fix this.

@mingo99
Copy link
Author

mingo99 commented Sep 8, 2024

Oh now I can reproduce it. Thanks! I'll try to figure out a good way to fix this.

Thanks,Looking forward to your good news.

mikavilpas added a commit that referenced this issue Sep 8, 2024
Issue
=

In the following scenario, when all of these happened, yazi would always
open when restoring a session:
- When using LazyVim / folke/persistence.nvim
- start neovim with `nvim .`
- open a file
- close neovim
- start neovim with `nvim`
- restore the last session with persistence.nvim

This seemed to happen because the session includes the `.` which was
given as an argument to neovim. Restoring the session would open the
directory in yazi.

Solution
=

The solution is to check if the `SessionLoad` variable is set to `1` and
skip opening yazi if it is. This is because the `SessionLoad` variable
is set to `1` when restoring a session.

See `:h SessionLoad-variable` for more information.

Fixes #440
@mikavilpas
Copy link
Owner

Should be fixed - let me know if there are any issues that remain.

Also, thanks for reporting this bug!

@mingo99
Copy link
Author

mingo99 commented Sep 9, 2024

Should be fixed - let me know if there are any issues that remain.

Also, thanks for reporting this bug!

Thanks,it has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants