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

feat(builtin.buffers): enhance and bind delete_buffer action #3145

Merged
merged 3 commits into from
Jun 15, 2024

Conversation

jamestrew
Copy link
Contributor

@jamestrew jamestrew commented May 30, 2024

Binds the delete_buffer action to <M-d> by default for the buffers pickers.

closes #3128

Also enhances the delete_buffer action to have a "cleaner" behavior for deleting the current buffer (the buffer under telescope). Previously, when deleting the current buffer, the buffer would be removed from the buflist but closing the picker would put you right back into the buffer you just deleted.
From :h bdelete:

If buffer [N] is the current buffer, another buffer will be displayed instead. This is the most recent entry in the jump list that points into a loaded buffer.

Since the telescope prompt buffer is technically the current buffer, this "another buffer will be displayed behavior" wasn't actually triggering.
With this newest change, Telescope will manually get the buffer of the most recent entry in the jumplist and change the window behind telescope to this new buffer.

closes #2643

Copy link
Member

@Conni2461 Conni2461 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides docs nit

lua/telescope/builtin/__internal.lua Outdated Show resolved Hide resolved
@Conni2461
Copy link
Member

Thanks :)

@jamestrew
Copy link
Contributor Author

Thanks, I agree about setting default mappings but it's such a common question I see here/reddit/discord so.
Switched it to <M-d> since I forgot that <C-x> is already a default mapping.

@jamestrew jamestrew merged commit 979bfa2 into nvim-telescope:master Jun 15, 2024
@jamestrew jamestrew deleted the buffer-delete-bind branch June 15, 2024 14:24
@igorlfs
Copy link

igorlfs commented Jun 15, 2024

Hey! This commit introduced a bug :(

I can no longer use :Telescope buffers. I get a stacktrace that points to
telescope.nvim/lua/telescope/mappings.lua:330: Attach mappings must always return a value. `true` means use default mappings, `false` means only use attached mappings. So I guess this should be retuning true?

EDIT: I went ahead and made a PR, see below

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 this pull request may close these issues.

[request] close buffer bind delete_buffer action does not close the current buffer
3 participants