From d43ab67d0eb4317961c5e9d15fffe908519debe0 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 25 Aug 2024 13:23:28 +1000 Subject: [PATCH] fix(#2879): remove unnecessary tree window width setting to prevent unnecessary :wincmd = (#2881) --- lua/nvim-tree/view.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index 1e9a412a875..f30eb2720a4 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -346,14 +346,18 @@ function M.resize(size) return end - local new_size = get_width() - vim.api.nvim_win_set_width(M.get_winnr() or 0, new_size) + local winnr = M.get_winnr() or 0 - events._dispatch_on_tree_resize(new_size) + local new_size = get_width() - if not M.View.preserve_window_proportions then - vim.cmd ":wincmd =" + if new_size ~= vim.api.nvim_win_get_width(winnr) then + vim.api.nvim_win_set_width(winnr, new_size) + if not M.View.preserve_window_proportions then + vim.cmd ":wincmd =" + end end + + events._dispatch_on_tree_resize(new_size) end function M.reposition_window()