@@ -14,7 +14,7 @@ local renderer = require("neo-tree.ui.renderer")
1414
1515local M = {}
1616
17- M .show_filter = function (state , search_as_you_type , fuzzy_finder_mode )
17+ M .show_filter = function (state , search_as_you_type , fuzzy_finder_mode , use_fzy )
1818 local popup_options
1919 local winid = vim .api .nvim_get_current_win ()
2020 local height = vim .api .nvim_win_get_height (winid )
@@ -55,6 +55,29 @@ M.show_filter = function(state, search_as_you_type, fuzzy_finder_mode)
5555 })
5656 end
5757
58+ local set_sort_by_score = function ()
59+ state .sort_function_override = function (a , b )
60+ -- `state.fzy_sort_result_scores` should be defined in
61+ -- `sources.filesystem.lib.filter_external.fzy_sort_files`
62+ local result_scores = state .fzy_sort_result_scores or { foo = 0 , baz = 0 }
63+ local a_score = result_scores [a .path ]
64+ local b_score = result_scores [b .path ]
65+ if a_score == nil or b_score == nil then
66+ log .debug (string.format ([[ Fzy: failed to compare %s: %s, %s: %s]] , a .path , a_score , b .path , b_score ))
67+ local config = require (" neo-tree" ).config
68+ if config .sort_function ~= nil then
69+ return config .sort_function (a , b )
70+ end
71+ return nil
72+ end
73+ return a_score > b_score
74+ end
75+ end
76+ if use_fzy then
77+ set_sort_by_score ()
78+ state .use_fzy = true
79+ end
80+
5881 local select_first_file = function ()
5982 local is_file = function (node )
6083 return node .type == " file"
0 commit comments