@@ -72,8 +72,21 @@ local function get_matching_paths(client, filters, paths)
72
72
glob = glob :gsub (" /" , " \\ " )
73
73
end
74
74
75
- --- @type nil | vim.lpeg.Pattern
76
- local glob_pattern = vim .glob and vim .glob .to_lpeg and vim .glob .to_lpeg (glob )
75
+ --- @type string | vim.lpeg.Pattern
76
+ local glob_to_match = glob
77
+ if vim .glob and vim .glob .to_lpeg then
78
+ -- HACK around https://github.com/neovim/neovim/issues/28931
79
+ -- find alternations and sort them by length to try to match the longest first
80
+ glob = glob :gsub (" {(.*)}" , function (s )
81
+ local pieces = vim .split (s , " ," )
82
+ table.sort (pieces , function (a , b )
83
+ return a :len () > b :len ()
84
+ end )
85
+ return " {" .. table.concat (pieces , " ," ) .. " }"
86
+ end )
87
+
88
+ glob_to_match = vim .glob .to_lpeg (glob )
89
+ end
77
90
local matches = pattern .matches
78
91
table.insert (match_fns , function (path )
79
92
local is_dir = vim .fn .isdirectory (path ) == 1
@@ -84,7 +97,7 @@ local function get_matching_paths(client, filters, paths)
84
97
if ignore_case then
85
98
path = path :lower ()
86
99
end
87
- return match_glob (glob_pattern or glob , path )
100
+ return match_glob (glob_to_match , path )
88
101
end )
89
102
end
90
103
end
0 commit comments