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

delete_buffer action does not close the current buffer #2643

Closed
tjvc opened this issue Aug 8, 2023 · 1 comment · Fixed by #3145
Closed

delete_buffer action does not close the current buffer #2643

tjvc opened this issue Aug 8, 2023 · 1 comment · Fixed by #3145
Labels
bug Something isn't working

Comments

@tjvc
Copy link

tjvc commented Aug 8, 2023

Description

The delete_buffer action does not close the current buffer if it is the only open buffer in the current tab.

Neovim version

NVIM v0.10.0-dev-774+g37c58226a-Homebrew
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

macOS 13.5

Telescope version / branch / rev

telescope 0.1.2

checkhealth telescope

telescope: health#telescope#check

Checking for required plugins ~
- OK plenary installed.
- WARNING nvim-treesitter not found. (Required for `:Telescope treesitter`.)

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.6.0

===== Installed extensions ===== ~

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Steps to reproduce

  1. Open one or more buffers
  2. Ensure that a single buffer is open in the current tab
  3. Open the Telescope buffers picker
  4. Try deleting the current buffer (mapped to <C-D> in the provided config)
  5. See that the buffer is not deleted

Expected behavior

The same as :bdelete <buffer number> on the current buffer: the buffer is deleted and another open buffer (if any) or the [No Name] buffer is displayed.

Actual behavior

The buffer is removed from the picker list but remains open.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup()
  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
  require("telescope").setup {
    pickers = {
      buffers = {
        mappings = {
          i = {
            ["<c-d>"] = "delete_buffer",
          }
        }
      }
    }
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
@tjvc tjvc added the bug Something isn't working label Aug 8, 2023
@jamestrew
Copy link
Contributor

I think this might be awkward to fix.

Doing :bdelete <bufnr> on the "current buffer" (aka the one behind telescope) while telescope is open, you don't get the expected behavior outlined in the issue description either. Looks like there's some strange interaction when deleting a buffer that's behind a floating buffer or something.

dkao added a commit to dkao/vim_settings that referenced this issue Oct 23, 2023
Covers all my bufexplorer use cases at this point
Pending nvim-telescope/telescope.nvim#2643
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

Successfully merging a pull request may close this issue.

2 participants