@@ -81,6 +81,7 @@ M.follow = function(callback, force_show)
81
81
end
82
82
end
83
83
84
+ state .position .is .restorable = false -- we will handle setting cursor position here
84
85
fs_scan .get_items_async (state , nil , path_to_reveal , function ()
85
86
local event = {
86
87
event = events .AFTER_RENDER ,
@@ -119,44 +120,15 @@ local navigate_internal = function(path, path_to_reveal, callback)
119
120
end
120
121
121
122
if path_to_reveal then
122
- fs_scan .get_items_async (state , nil , path_to_reveal , function ()
123
- renderer .focus_node (state , path_to_reveal )
124
- if callback then
125
- callback ()
126
- end
127
- state .in_navigate = false
128
- end )
123
+ state .position .set (path_to_reveal )
124
+ fs_scan .get_items_async (state , nil , path_to_reveal , callback )
129
125
else
130
126
local follow_file = state .follow_current_file and manager .get_path_to_reveal ()
131
127
if utils .truthy (follow_file ) then
132
- M .follow (function ()
133
- if callback then
134
- callback ()
135
- end
136
- state .in_navigate = false
137
- end , true )
128
+ M .follow (callback , true )
138
129
else
139
- local previously_focused = nil
140
- if state .tree and renderer .is_window_valid (state .winid ) then
141
- local node = state .tree :get_node ()
142
- if node then
143
- -- keep the current node selected
144
- previously_focused = node :get_id ()
145
- end
146
- end
147
- fs_scan .get_items_async (state , nil , nil , function ()
148
- local current_winid = vim .api .nvim_get_current_win ()
149
- if path_changed and current_winid == state .winid and previously_focused then
150
- local currently_focused = state .tree :get_node ():get_id ()
151
- if currently_focused ~= previously_focused then
152
- renderer .focus_node (state , previously_focused , false )
153
- end
154
- end
155
- if callback then
156
- callback ()
157
- end
158
- state .in_navigate = false
159
- end )
130
+ state .position .save ()
131
+ fs_scan .get_items_async (state , nil , nil , callback )
160
132
end
161
133
end
162
134
0 commit comments