@@ -190,63 +190,60 @@ M.show_filter = function(state, search_as_you_type, fuzzy_finder_mode, use_fzy)
190190 vim .api .nvim_win_set_height (winid , height )
191191 end
192192 end )
193- local close_input = function ()
194- vim .cmd (" stopinsert" )
195- input :unmount ()
196- -- If this was closed due to submit, that function will handle the reset_search
197- vim .defer_fn (function ()
198- if fuzzy_finder_mode and utils .truthy (state .search_pattern ) then
199- fs .reset_search (state , true )
200- end
201- end , 100 )
202- restore_height ()
203- end
193+ local cmds = {
194+ move_cursor_down = function (_state , _scroll_padding )
195+ renderer .focus_node (_state , nil , true , 1 , _scroll_padding )
196+ end ,
197+
198+ move_cursor_up = function (_state , _scroll_padding )
199+ renderer .focus_node (_state , nil , true , - 1 , _scroll_padding )
200+ vim .cmd (" redraw!" )
201+ end ,
202+
203+ close = function ()
204+ vim .cmd (" stopinsert" )
205+ input :unmount ()
206+ -- If this was closed due to submit, that function will handle the reset_search
207+ vim .defer_fn (function ()
208+ if fuzzy_finder_mode and utils .truthy (state .search_pattern ) then
209+ fs .reset_search (state , true )
210+ end
211+ end , 100 )
212+ restore_height ()
213+ end ,
214+ }
204215
205- input :on ({ event .BufLeave , event .BufDelete }, close_input , { once = true })
216+ input :on ({ event .BufLeave , event .BufDelete }, cmds . close , { once = true })
206217
207218 input :map (" i" , " <C-w>" , " <C-S-w>" , { noremap = true })
208219
209- if fuzzy_finder_mode then
210- local cmds = {
211- move_cursor_down = function (_state , _scroll_padding )
212- renderer .focus_node (_state , nil , true , 1 , _scroll_padding )
213- end ,
214-
215- move_cursor_up = function (_state , _scroll_padding )
216- renderer .focus_node (_state , nil , true , - 1 , _scroll_padding )
217- vim .cmd (" redraw!" )
218- end ,
219-
220- close = function ()
221- close_input ()
222- end ,
223- }
224- for lhs , cmd_name in pairs (require (" neo-tree" ).config .filesystem .window .fuzzy_finder_mappings ) do
225- local t = type (cmd_name )
226- if t == " string" then
227- local cmd = cmds [cmd_name ]
228- if cmd then
229- input :map (
230- " i" ,
231- lhs ,
232- create_input_mapping_handle (cmd , state , scroll_padding ),
233- { noremap = true }
234- )
235- else
236- log .warn (
237- string.format (" Invalid command in fuzzy_finder_mappings: %s = %s" , lhs , cmd_name )
238- )
239- end
240- elseif t == " function" then
220+ if not fuzzy_finder_mode then
221+ return
222+ end
223+
224+ for lhs , cmd_name in pairs (require (" neo-tree" ).config .filesystem .window .fuzzy_finder_mappings ) do
225+ local t = type (cmd_name )
226+ if t == " string" then
227+ local cmd = cmds [cmd_name ]
228+ if cmd then
241229 input :map (
242230 " i" ,
243231 lhs ,
244- create_input_mapping_handle (cmd_name , state , scroll_padding ),
232+ create_input_mapping_handle (cmd , state , scroll_padding ),
245233 { noremap = true }
246234 )
247235 else
248236 log .warn (string.format (" Invalid command in fuzzy_finder_mappings: %s = %s" , lhs , cmd_name ))
249237 end
238+ elseif t == " function" then
239+ input :map (
240+ " i" ,
241+ lhs ,
242+ create_input_mapping_handle (cmd_name , state , scroll_padding ),
243+ { noremap = true }
244+ )
245+ else
246+ log .warn (string.format (" Invalid command in fuzzy_finder_mappings: %s = %s" , lhs , cmd_name ))
250247 end
251248 end
252249end
0 commit comments