Skip to content

Worked Around: Telescope Invalid Window ID 10xx On Opening Large File: Disable actions.open_file.eject #3151

@jzho987

Description

@jzho987

Description

Not sure if this is the right place for this bug. But I suspect NvimTree could be the problem.

When opening a file of ~ 1-2k lines on my machine using Telescope. The neovim treesitter api complains about invalid window ID. Which is the window ID of the NvimTree window. This leads to any long files not having syntax highlighting when using these plugins.

Neovim version

NVIM v0.11.2
Build type: RelWithDebInfo
LuaJIT 2.1.1748459687

Operating system and version

Linux 6.15.2-arch1-1

Windows variant

No response

nvim-tree version

v1.13.0

Clean room replication

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvt-min/site]])
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup({
    {
      "wbthomason/packer.nvim",
      "nvim-tree/nvim-tree.lua",
      "nvim-tree/nvim-web-devicons",
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
      "nvim-treesitter/nvim-treesitter", 
      -- 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
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing nvim-tree 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 setup()]])
vim.opt.termguicolors = true
vim.opt.cursorline = true

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup({})

  -- Setup treesitter as it contributes to the failure.
  require'nvim-treesitter.configs'.setup {
    ensure_installed = { 
      "lua",
    },
    sync_install = true,
    highlight = { enable = true }
  }
end

Steps to reproduce

  1. nvim -nu /tmp/nvt-min.lua
  2. :NvimTreeOpen
  3. Run this to check the window id of the NvimTree buffer: :lua for i = 1, vim.fn.winnr('$') do print('Window ' .. i .. ' ID: ' .. vim.fn.win_getid(i)) end
  4. Move cursor to NvimTreeBuffer
  5. :Telescope find_files
  6. Choose a large file. Example: https://github.com/jzho987/nvim/blob/bug-setup/long.lua
  7. Jump to said file.

Expected behavior

Expected the file to correctly open, and syntax highlight to work. No errors should be thrown.

Actual behavior

Error gets thrown. Syntax highlighting no longer works.

Image

Note the nvimtree window id should be the same as what was printed in the step 3

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