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

Handle unlisted buffers while Cybu window is open #19

Open
sQVe opened this issue Apr 19, 2023 · 4 comments
Open

Handle unlisted buffers while Cybu window is open #19

sQVe opened this issue Apr 19, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@sQVe
Copy link

sQVe commented Apr 19, 2023

👋🏼,

First off, I want to say thank you - I'm really loving this plugin!


In my setup, I use bufignore.nvim to unlist Git ignored buffers once they are hidden. However, I've encountered an issue with Cybu when I move through the entire list of buffers it provides. When it encounters an unlisted buffer, Cybu silently stops working, and I have to use bnext to move to another listed buffer.

This behavior can be easily replicated with the following steps:

  1. Open multiple buffers.
  2. Use vim.defer.fn to unlist one of the buffers with a delay of 1-2 seconds.
  3. Continuously cycle through the items in the Cybu window.
  4. Once it reaches the unlisted buffer, Cybu fails to go to the next buffer silently.
@ghillb ghillb added the bug Something isn't working label Apr 19, 2023
@ghillb ghillb self-assigned this Apr 19, 2023
@ghillb
Copy link
Owner

ghillb commented Apr 19, 2023

👋🏼, Glad you like it, and thank you for reporting the issue.

Based on your description, I was able to reproduce the issue. Previously, there was a hard-coded filter for unlisted buffers, which activated the fallback, which per default does nothing.

I have added a new config option (e74c3fa) that allows you to turn off the filter for unlisted buffers. By setting filter = { unlisted = false } in your config, Cybu will no longer stop working when cycling through unlisted buffers. I have plans for further improvements in handling and filtering unlisted buffers, but for now, I hope this new option resolves the issue.

Steps to reproduce
  1. Execute the following command.
lua vim.defer_fn(function() vim.api.nvim_buf_set_option(2, 'buflisted', false) end, 1500)
  1. Cycle until the delisted buffer is reached

@sQVe
Copy link
Author

sQVe commented Apr 20, 2023

@ghillb Yeah, that fixes the issue of Cybu not working on unlisted buffers. Sadly, this counters the reason I'm using bufignore.nvim. There is no need to unlist buffers if I'm able to cycle thorough all buffers, including unlisted ones.

One solution, that I'm guessing would be possible, is to add a fallback to the cycle command. If cycle fails to run either bnext or bprevious, or even better allow the user to supply a fallback.

sQVe added a commit to sQVe/dotfiles that referenced this issue Apr 20, 2023
We're disabling this plugin since it doesn't play nicely with unlisted
buffers. Will enable it again once
ghillb/cybu.nvim#19 is resolved.
@ghillb
Copy link
Owner

ghillb commented Apr 20, 2023

Could you please test if the fallback setting can handle your use case? I just added the possibility to grab direction (values: "next" or "prev"), and mode (values: "default", "last_used" or"auto") parameters in the fallback (d15cd01). You can find the conditions on when the fallback is called here.

Example:

fallback = function(direction, mode)
  if direction == "next" then
    vim.cmd("bnext")
  else
    vim.cmd("bprev")
  end
end,

@sQVe
Copy link
Author

sQVe commented Apr 20, 2023

That looks like an awesome solution. It sort of works but there seems to be a bug. I have to run cycle sometime twice for a unlisted buffer and the Cybu window gets unsynced from the visible buffer. See screenrecording:

recording-2023-04-20_10.27.30.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants