@@ -14,9 +14,9 @@ function M.toggle()
1414 lib .close ()
1515 else
1616 if vim .g .nvim_tree_follow == 1 then
17- vim . schedule ( function () M .find_file (true ) end )
17+ M .find_file (true )
1818 else
19- vim . schedule ( lib .open )
19+ lib .open ( )
2020 end
2121 end
2222end
@@ -28,27 +28,21 @@ function M.close()
2828 end
2929end
3030
31- function M .open (cb )
32- vim .schedule (
33- function ()
34- if not lib .win_open () then
35- lib .open ()
36- else
37- lib .set_target_win ()
38- end
39- pcall (cb )
40- end
41- )
31+ function M .open ()
32+ if not lib .win_open () then
33+ lib .open ()
34+ else
35+ lib .set_target_win ()
36+ end
4237end
4338
4439local winopts = config .window_options ()
4540function M .tab_change ()
4641 -- we need defer_fn to make sure we close/open after we enter the tab
4742 vim .defer_fn (function ()
4843 if M .close () then
49- M .open (function ()
50- api .nvim_command (' wincmd ' .. winopts .open_command )
51- end )
44+ M .open ()
45+ api .nvim_command (' wincmd ' .. winopts .open_command )
5246 end
5347 end , 1 )
5448end
@@ -82,7 +76,7 @@ local keypress_funcs = {
8276 prev_git_item = gen_go_to (' prev_git_item' ),
8377 next_git_item = gen_go_to (' next_git_item' ),
8478 dir_up = lib .dir_up ,
85- close = function (node ) M .close () end ,
79+ close = function () M .close () end ,
8680 preview = function (node )
8781 if node .entries ~= nil or node .name == ' ..' then return end
8882 return lib .open_file (' preview' , node .absolute_path )
@@ -153,13 +147,11 @@ function M.find_file(with_open)
153147 local filepath = vim .fn .fnamemodify (bufname , ' :p' )
154148
155149 if with_open then
156- return M .open (
157- function ()
158- lib .win_focus ()
159- if not is_file_readable (filepath ) then return end
160- lib .set_index_and_redraw (filepath )
161- end
162- )
150+ M .open ()
151+ lib .win_focus ()
152+ if not is_file_readable (filepath ) then return end
153+ lib .set_index_and_redraw (filepath )
154+ return
163155 end
164156
165157 if not is_file_readable (filepath ) then return end
0 commit comments