Skip to content

Bugs after toggle preview #3605

@eeeXun

Description

@eeeXun

Description

When :Telescope find_files. You toggle preview window (close and open it again). Then telescope would crash if you select other files while the preview window was open.

Neovim version

NVIM v0.11.5
Build type: RelWithDebInfo
LuaJIT 2.1.1763318511

Operating system and version

6.17.9-arch1-1

Telescope version / branch / rev

telescope 0.2.1

checkhealth telescope

telescope:                                                                1 ⚠️

Checking for required plugins ~
- ✅ OK plenary installed.

Checking external dependencies ~
- ✅ OK rg: found ripgrep 15.1.0
- ⚠️ WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

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

Steps to reproduce

  1. nvim -nu minimal.lua
  2. :Telescope find_files
  3. Press <C-h>, which I use in minimal.lua below, to close preview window
  4. Press <C-h> again to open the preview window
  5. Select other files with <C-n> or <C-p>

Expected behavior

No response

Actual behavior

The log

E5108: Error executing lua: ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:439: Invalid window id: 1014
stack traceback:                                                                                                                    
        [C]: in function '__newindex'                                                                                               
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:439: in function 'preview'                                      
        .../.repro/plugins/telescope.nvim/lua/telescope/pickers.lua:1209: in function 'refresh_previewer'                           
        .../.repro/plugins/telescope.nvim/lua/telescope/pickers.lua:1150: in function 'set_selection'                               
        .../.repro/plugins/telescope.nvim/lua/telescope/pickers.lua:910: in function 'move_selection'                               
        ...pro/plugins/telescope.nvim/lua/telescope/actions/set.lua:39: in function 'run_replace_or_original'                       
        ...epro/plugins/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'shift_selection'                               
        ...ro/plugins/telescope.nvim/lua/telescope/actions/init.lua:87: in function 'run_replace_or_original'                       
        ...epro/plugins/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'                                      
        ....repro/plugins/telescope.nvim/lua/telescope/mappings.lua:293: in function <....repro/plugins/telescope.nvim/lua/telescope
/mappings.lua:292>

Minimal config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
  vim.fn.system {
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-telescope/telescope.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
    },
    config = function()
      -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
      require("telescope").setup {
        defaults = {
          mappings = {
            i = {
              ["<C-h>"] = require("telescope.actions.layout").toggle_preview,
            },
          },
        },
      }
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions