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

[Feature] Restrict closing-by-search-term to only close a buffer if a single buffer matches the term. #50

Open
neandrake opened this issue Dec 28, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@neandrake
Copy link

Is your feature request related to a problem? Please describe.
When using Bdelete or Bwipe with a text/string parameter to close a buffer, if the term matches multiple buffers one will be closed seemingly at random. This is particularly problematic when a buffer's relative file path matches the term and not the file name.

Example:
My neovim config directory has the following files:

  • lua/neandrake/lazy.lua
  • lua/neandrake/lazy_plugins/bufdelete.lua
  • lua/neandrake/lazy_plugins/... .lua

I then run :Bdel lazy with the intent to close lazy.lua but bufdelete.lua ends up closing. This happens because the buffer's name is the relative-to-cwd path + filename of the file, in this case lua/neandrake/lazy_plugins/bufdelete.lua and lazy matched the path element lazy_plugins. Presumably this would happen not at random but first match in order of what buffers were opened first.

Describe the solution you'd like
Update matching behavior, or an option to do so, such that if multiple buffers match the search term then no buffers are closed. Alternatively only match on the filename part of the name, if it's reliable to do so.

Describe alternatives you've considered
Closing by buffer ID instead of by name matching.

Additional context
I use bufferline plugin to show UI-tabs for opened buffers, configured to display only the buffer's filename for each UI-tab. When using :Bd lazy I was confused to what happened as something had closed but not lazy.lua.

@neandrake neandrake added the enhancement New feature or request label Dec 28, 2023
@neandrake neandrake changed the title [Feature] [Feature] Restrict closing-by-search-term to only close a buffer if a single buffer matches the term. Dec 28, 2023
@famiu
Copy link
Owner

famiu commented Dec 28, 2023

How does :bdelete behave in this situation? Does :Bdelete have the same behavior as :bdelete?

@neandrake
Copy link
Author

Using :bdelete lazy gives an error:

E93: More than one match for lazy
Screenshot 2023-12-28 at 1 43 25 PM

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

No branches or pull requests

2 participants