From 5af3cfa1702e3cb876a3ba1582444e8d4c5b2544 Mon Sep 17 00:00:00 2001 From: kiyan Date: Wed, 9 Mar 2022 22:29:26 +0100 Subject: [PATCH] fix: split if nvim-tree is the only window also fix resize when trying to open but the buffer exists --- lua/nvim-tree/actions/open-file.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/nvim-tree/actions/open-file.lua b/lua/nvim-tree/actions/open-file.lua index 04252df1..02d9883b 100644 --- a/lua/nvim-tree/actions/open-file.lua +++ b/lua/nvim-tree/actions/open-file.lua @@ -204,7 +204,7 @@ function M.fn(mode, filename) end local cmd - if do_split then + if do_split or #api.nvim_list_wins() == 1 then cmd = string.format("%ssplit ", vertical and "vertical " or "") else cmd = "edit " @@ -213,9 +213,10 @@ function M.fn(mode, filename) cmd = cmd .. vim.fn.fnameescape(filename) api.nvim_set_current_win(target_winid) pcall(vim.cmd, cmd) - if M.resize_window then - view.resize() - end + end + + if M.resize_window then + view.resize() end if mode == "preview" then