@@ -27,7 +27,7 @@ M.reveal_current_file = function()
2727 return manager .reveal_current_file (M .name )
2828end
2929
30- local follow_internal = function (callback , force_show )
30+ local follow_internal = function (callback , force_show , async )
3131 log .trace (" follow called" )
3232 if vim .bo .filetype == " neo-tree" or vim .bo .filetype == " neo-tree-popup" then
3333 return
@@ -97,7 +97,7 @@ local follow_internal = function(callback, force_show)
9797 if type (callback ) == " function" then
9898 callback ()
9999 end
100- end )
100+ end , async )
101101 return true
102102end
103103
@@ -110,7 +110,7 @@ M.follow = function(callback, force_show)
110110 end , 100 , utils .debounce_strategy .CALL_LAST_ONLY )
111111end
112112
113- M ._navigate_internal = function (state , path , path_to_reveal , callback )
113+ M ._navigate_internal = function (state , path , path_to_reveal , callback , async )
114114 log .trace (" navigate_internal" , state .current_position , path , path_to_reveal )
115115 state .dirty = false
116116 local is_search = utils .truthy (state .search_pattern )
@@ -135,14 +135,14 @@ M._navigate_internal = function(state, path, path_to_reveal, callback)
135135 )
136136 fs_scan .get_items (state , nil , path_to_reveal , callback )
137137 else
138- local is_split = state .current_position == " current"
138+ local is_current = state .current_position == " current"
139139 local follow_file = state .follow_current_file
140140 and not is_search
141- and not is_split
141+ and not is_current
142142 and manager .get_path_to_reveal ()
143143 local handled = false
144144 if utils .truthy (follow_file ) then
145- handled = follow_internal (callback , true )
145+ handled = follow_internal (callback , true , async )
146146 end
147147 if not handled then
148148 local success , msg = pcall (renderer .position .save , state )
@@ -151,7 +151,7 @@ M._navigate_internal = function(state, path, path_to_reveal, callback)
151151 else
152152 log .trace (" navigate_internal: FAILED to save position: " , msg )
153153 end
154- fs_scan .get_items (state , nil , nil , callback )
154+ fs_scan .get_items (state , nil , nil , callback , async )
155155 end
156156 end
157157
@@ -168,10 +168,10 @@ end
168168--- @param path string Path to navigate to. If empty , will navigate to the cwd.
169169--- @param path_to_reveal string Node to focus after the items are loaded.
170170--- @param callback function Callback to call after the items are loaded.
171- M .navigate = function (state , path , path_to_reveal , callback )
172- log .trace (" navigate" , path , path_to_reveal )
171+ M .navigate = function (state , path , path_to_reveal , callback , async )
172+ log .trace (" navigate" , path , path_to_reveal , async )
173173 utils .debounce (" filesystem_navigate" , function ()
174- M ._navigate_internal (state , path , path_to_reveal , callback )
174+ M ._navigate_internal (state , path , path_to_reveal , callback , async )
175175 end , utils .debounce_strategy .CALL_FIRST_AND_LAST , 100 )
176176end
177177
@@ -340,7 +340,16 @@ M.setup = function(config, global_config)
340340 -- Update the "modified" component
341341 manager .subscribe (M .name , {
342342 event = events .VIM_BUFFER_MODIFIED_SET ,
343- handler = wrap (manager .redraw )
343+ handler = function (arg )
344+ local afile = arg .afile or " "
345+ local source = afile :match (" ^neo%-tree ([%l%-]+) %[%d+%]" )
346+ if source then
347+ log .trace (" Ignoring vim_modified_set event from " .. source )
348+ return
349+ end
350+ log .trace (" refreshing due to vim_modified_set event: " , afile )
351+ manager .redraw (M .name )
352+ end
344353 })
345354end
346355
0 commit comments