@@ -14,7 +14,7 @@ local renderer = require("neo-tree.ui.renderer")
14
14
15
15
local M = {}
16
16
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 )
18
18
local popup_options
19
19
local winid = vim .api .nvim_get_current_win ()
20
20
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)
55
55
})
56
56
end
57
57
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
+
58
81
local select_first_file = function ()
59
82
local is_file = function (node )
60
83
return node .type == " file"
0 commit comments