File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -358,7 +358,7 @@ local function setup_vim_commands()
358
358
command! NvimTreeClose lua require'nvim-tree'.close()
359
359
command! NvimTreeToggle lua require'nvim-tree'.toggle()
360
360
command! NvimTreeFocus lua require'nvim-tree'.focus()
361
- command! NvimTreeRefresh lua require'nvim-tree'.refresh( )
361
+ command! NvimTreeRefresh lua require'nvim-tree.lib'.refresh_tree(true )
362
362
command! NvimTreeClipboard lua require'nvim-tree'.print_clipboard()
363
363
command! NvimTreeFindFile lua require'nvim-tree'.find_file(true)
364
364
command! -nargs=1 NvimTreeResize lua require'nvim-tree'.resize(<args>)
@@ -398,6 +398,7 @@ local function setup_autocommands(opts)
398
398
if opts .update_focused_file .enable then
399
399
vim .cmd " au BufEnter * lua require'nvim-tree'.find_file(false)"
400
400
end
401
+ vim .cmd " au BufUnload NvimTree lua require'nvim-tree.view'.View.winnr = {}"
401
402
402
403
vim .cmd " augroup end"
403
404
end
Original file line number Diff line number Diff line change @@ -460,12 +460,15 @@ function M.open()
460
460
M .set_target_win ()
461
461
462
462
local cwd = vim .fn .getcwd ()
463
- view .open ()
463
+ local should_redraw = view .open ()
464
464
465
465
local respect_buf_cwd = vim .g .nvim_tree_respect_buf_cwd or 0
466
466
if respect_buf_cwd == 1 and cwd ~= M .Tree .cwd then
467
467
M .change_dir (cwd )
468
468
end
469
+ if should_redraw then
470
+ M .redraw ()
471
+ end
469
472
end
470
473
471
474
function M .sibling (node , direction )
Original file line number Diff line number Diff line change @@ -302,7 +302,9 @@ local function is_buf_valid(bufnr)
302
302
end
303
303
304
304
function M .open (options )
305
+ local should_redraw = false
305
306
if not is_buf_valid (M .View .bufnr ) then
307
+ should_redraw = true
306
308
create_buffer ()
307
309
end
308
310
@@ -320,6 +322,7 @@ function M.open(options)
320
322
if not opts .focus_tree then
321
323
vim .cmd (" wincmd p" )
322
324
end
325
+ return should_redraw
323
326
end
324
327
325
328
local function get_existing_buffers ()
You can’t perform that action at this time.
0 commit comments