From 995317cc24861a91722420083f1bba9f16cd339d Mon Sep 17 00:00:00 2001 From: Maximiliano Curia Date: Wed, 16 Mar 2022 10:09:54 +0100 Subject: [PATCH] Set target window whenever we open "open" a visible tree Currently the target window to be used (with a disabled pick window) is the one that was "focused" when the tree was first opened. So, if you let the tree open, the splits and open file are going to target the original window. This is counter intuitive and annoying if what you want to achieve is to open a file in a split. This minor change updates the target window whenever we try to open the tree, that's executed whenever we focus the tree, so the behaviour is now that the splits and open_file are executed against the previously focussed buffer. --- lua/nvim-tree.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 4800ab1af9d..063da8f11f3 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -41,6 +41,7 @@ end function M.open(cwd) cwd = cwd ~= "" and cwd or nil if view.is_visible() then + lib.set_target_win() view.focus() else lib.open(cwd)