File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ local modified = require "nvim-tree.modified"
15
15
local keymap_legacy = require " nvim-tree.keymap-legacy"
16
16
local find_file = require " nvim-tree.actions.tree.find-file"
17
17
local open = require " nvim-tree.actions.tree.open"
18
+ local events = require " nvim-tree.events"
18
19
19
20
local _config = {}
20
21
@@ -337,6 +338,21 @@ local function setup_autocommands(opts)
337
338
end ,
338
339
})
339
340
end
341
+
342
+ -- TODO #1545 remove similar check from view.resize
343
+ if vim .fn .has " nvim-0.9" == 1 then
344
+ create_nvim_tree_autocmd (" WinResized" , {
345
+ callback = function ()
346
+ if vim .v .event and vim .v .event .windows then
347
+ for _ , winid in ipairs (vim .v .event .windows ) do
348
+ if vim .api .nvim_win_is_valid (winid ) and utils .is_nvim_tree_buf (vim .api .nvim_win_get_buf (winid )) then
349
+ events ._dispatch_on_tree_resize (vim .api .nvim_win_get_width (winid ))
350
+ end
351
+ end
352
+ end
353
+ end ,
354
+ })
355
+ end
340
356
end
341
357
342
358
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
Original file line number Diff line number Diff line change @@ -434,7 +434,7 @@ function M.is_nvim_tree_buf(bufnr)
434
434
if bufnr == nil then
435
435
bufnr = 0
436
436
end
437
- if vim .fn . bufexists (bufnr ) then
437
+ if vim .api . nvim_buf_is_valid (bufnr ) then
438
438
local bufname = vim .api .nvim_buf_get_name (bufnr )
439
439
if vim .fn .fnamemodify (bufname , " :t" ):match " ^NvimTree_[0-9]+$" then
440
440
if vim .bo [bufnr ].filetype == " NvimTree" then
Original file line number Diff line number Diff line change @@ -330,7 +330,11 @@ function M.resize(size)
330
330
local new_size = get_width ()
331
331
vim .api .nvim_win_set_width (M .get_winnr (), new_size )
332
332
333
- events ._dispatch_on_tree_resize (new_size )
333
+ -- TODO #1545 remove similar check from setup_autocommands
334
+ -- We let nvim handle sending resize events after 0.9
335
+ if vim .fn .has " nvim-0.9" == 0 then
336
+ events ._dispatch_on_tree_resize (new_size )
337
+ end
334
338
335
339
if not M .View .preserve_window_proportions then
336
340
vim .cmd " :wincmd ="
You can’t perform that action at this time.
0 commit comments