@@ -46,58 +46,6 @@ local get_path_to_reveal = function()
4646 return path
4747end
4848
49- local reveal_file = function (state , path )
50- if not path then
51- return nil
52- end
53- local tree = state .tree
54- if not tree then
55- return false
56- end
57- local node = tree :get_node (path )
58- if not node then
59- return false
60- end
61- -- expand_to_root(tree, node)
62- -- tree:render()
63-
64- local bufnr = utils .get_value (state , " bufnr" , 0 , true )
65- if bufnr == 0 then
66- return false
67- end
68- if not vim .api .nvim_buf_is_valid (bufnr ) then
69- return false
70- end
71- local lines = vim .api .nvim_buf_line_count (state .bufnr )
72- local linenr = 0
73- while linenr < lines do
74- linenr = linenr + 1
75- node = tree :get_node (linenr )
76- if node then
77- if node :get_id () == path then
78- local col = 0
79- if node .indent then
80- col = string.len (node .indent )
81- end
82- if renderer .window_exists (state ) then
83- vim .api .nvim_set_current_win (state .winid )
84- else
85- renderer .draw (state .tree :get_nodes (), state , nil )
86- end
87- local success , err = pcall (vim .api .nvim_win_set_cursor , state .winid , { linenr , col })
88- if not success then
89- print (" Failed to set cursor: " .. err )
90- end
91- return success
92- end
93- else
94- -- must be out of nodes
95- return false
96- end
97- end
98- return false
99- end
100-
10149M .close = function ()
10250 local state = get_state ()
10351 renderer .close (state )
@@ -157,7 +105,7 @@ M.navigate = function(path, path_to_reveal, callback)
157105
158106 if path_to_reveal then
159107 fs_scan .get_items_async (state , nil , path_to_reveal , function ()
160- local found = reveal_file (state , path_to_reveal )
108+ local found = renderer . focus_node (state , path_to_reveal )
161109 if not found and was_float then
162110 -- I'm not realy sure why it is not focused when it is created...
163111 -- vim.api.nvim_set_current_win(state.winid)
@@ -198,7 +146,7 @@ M.reveal_current_file = function()
198146 return
199147 end
200148 if path then
201- if not reveal_file (state , path ) then
149+ if not renderer . focus_node (state , path ) then
202150 M .focus (path )
203151 end
204152 end
0 commit comments