Skip to content

Error when calling preview when on floating mode #1643

@Almo7aya

Description

@Almo7aya

Description

Clicking <Tab> to preview a file when floating mode is enabled results to Invalid window id: 1002 error

image

The issue occurs in this line https://github.com/nvim-tree/nvim-tree.lua/blob/master/lua/nvim-tree/view.lua#L339 since nvim-tree on floating mode is auto_closed by default, the winnr is always invalid since the window is already gone, I suggest using a.nvim_win_is_valid(wnr) before trying to focus the window.

I'm not sure what is the expected behavior here, should it reopens the floating window again when previewing a file

Neovim version

NVIM v0.9.0-dev-1214-ge54541f7f-dirty
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

MacOS 12.6

nvim-tree version

main - b01e7be

Minimal config

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",
			"kyazdani42/nvim-tree.lua",
			"kyazdani42/nvim-web-devicons",
			-- 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({
		view = {
			float = {
				enable = true,
			},
		},
	})
end

vim.api.nvim_set_keymap("n", "<Space>e", "<cmd>:NvimTreeToggle<CR>", {})

Steps to reproduce

1- nvim -nu /tmp/nvt-min.lua
2- :NvimTreeToggle
3- press <Tab> on any file

Expected behavior

No response

Actual behavior

No response

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