11local vim = vim
22local log = require (" neo-tree.log" )
33local Job = require (" plenary.job" )
4+ local utils = require (" neo-tree.utils" )
45
56local M = {}
67local fd_supports_max_results = nil
@@ -47,10 +48,21 @@ M.find_files = function(opts)
4748 local limit = opts .limit or 200
4849 local cmd = get_find_command (opts )
4950 local path = opts .path
50- local term = opts .term
51+ local full_path_words = opts .find_by_full_path_words
52+ local regex , glob = opts .term , opts .term
5153
52- if term ~= " *" and not term :find (" *" ) then
53- term = " *" .. term .. " *"
54+ if full_path_words then
55+ local words = utils .split (glob , " " )
56+ regex = " .*" .. table.concat (words , " .*" ) .. " .*"
57+ else
58+ if glob ~= " *" then
59+ if glob :sub (1 ) ~= " *" then
60+ glob = " *" .. glob
61+ end
62+ if glob :sub (- 1 ) ~= " *" then
63+ glob = glob .. " *"
64+ end
65+ end
5466 end
5567
5668 local args = {}
@@ -67,7 +79,12 @@ M.find_files = function(opts)
6779 if not filters .respect_gitignore then
6880 append (" --no-ignore" )
6981 end
70- append (" --glob" , term , path )
82+ if full_path_words then
83+ append (" --full-path" , regex )
84+ else
85+ append (" --glob" , glob )
86+ end
87+ append (path )
7188 append (" --color" , " never" )
7289 if fd_supports_max_results then
7390 append (" --max-results" , limit )
@@ -78,9 +95,17 @@ M.find_files = function(opts)
7895 if not filters .show_hidden then
7996 append (" -not" , " -path" , " */.*" )
8097 end
81- append (" -iname" , term )
98+ if full_path_words then
99+ append (" -regextype" , " sed" , " -regex" , regex )
100+ else
101+ append (" -iname" , glob )
102+ end
103+ elseif cmd == " fzf" then
104+ -- This does not work yet, there's some kind of issue with how fzf uses stdout
105+ error (" fzf is not a supported find_command" )
106+ append (" --no-sort" , " --no-expect" , " --filter" , opts .term ) -- using the raw term without glob patterns
82107 elseif cmd == " where" then
83- append (" /r" , path , term )
108+ append (" /r" , path , glob )
84109 else
85110 return { " No search command found!" }
86111 end
@@ -91,13 +116,15 @@ M.find_files = function(opts)
91116 elseif type (opts .find_args ) == " table" then
92117 append (unpack (opts .find_args ))
93118 elseif type (opts .find_args ) == " function" then
94- args = opts .find_args (cmd , path , term , args )
119+ args = opts .find_args (cmd , path , glob , args )
95120 end
96121 end
97122
123+ log .info (cmd , args )
98124 Job
99125 :new ({
100126 command = cmd ,
127+ cwd = path ,
101128 args = args ,
102129 enable_recording = false ,
103130 maximum_results = limit or 100 ,
@@ -114,7 +141,7 @@ M.find_files = function(opts)
114141 opts .on_insert (err , line )
115142 end
116143 end ,
117- on_exit = function (j , return_val )
144+ on_exit = function (_ , return_val )
118145 if opts .on_exit then
119146 opts .on_exit (return_val )
120147 end
0 commit comments