From 56edf79b4b9a34b16b987d0cde33f544f93023c2 Mon Sep 17 00:00:00 2001 From: kiyan Date: Mon, 21 Feb 2022 23:25:02 +0100 Subject: [PATCH] fix(auto_close): abort when win closed is telescope fixes #609 --- lua/nvim-tree.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index b116f6e5..297b0b94 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -127,7 +127,17 @@ end M.resize = view.resize -function M.on_leave() +local function should_abort_auto_close() + local buf = api.nvim_get_current_buf() + local buftype = api.nvim_buf_get_option(buf, 'ft') + return buftype:match('Telescope') ~= nil +end + +function M.auto_close() + if should_abort_auto_close() then + return + end + vim.defer_fn(function() if not view.is_visible() then return @@ -270,7 +280,7 @@ local function setup_autocommands(opts) vim.cmd "au User FugitiveChanged,NeogitStatusRefreshed lua require'nvim-tree.actions.reloaders'.reload_git()" if opts.auto_close then - vim.cmd "au WinClosed * lua require'nvim-tree'.on_leave()" + vim.cmd "au WinClosed * lua require'nvim-tree'.auto_close()" end if opts.open_on_tab then vim.cmd "au TabEnter * lua require'nvim-tree'.tab_change()"