Skip to content

Commit 9642876

Browse files
committed
Simplify ApplySearchDirectoriesToFileTargetList
1 parent 766f4fe commit 9642876

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

plugin/EasyGrep.vim

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ function! s:GetBufferDirsList()
142142
if empty(d)
143143
let d = currDir
144144
elseif has("win32") && d[0] == "/"
145-
" Add the drive prefix and remove the trailing slash
146-
let d = fnamemodify(d, ":p:s-/$--")
145+
" Remove the trailing slash
146+
let d = fnamemodify(d, ":s-/$--")
147147
endif
148148
let dirs[d]=1
149149
endfor
@@ -551,7 +551,7 @@ function! s:GetGrepRootEx()
551551
endif
552552

553553
let type = "builtin"
554-
let pathtoreturn = s:GetCwdEscaped()
554+
let pathtoreturn = "."
555555
if !exists("g:EasyGrepRoot")
556556
" this is ok; act as if we are specified as "cwd"
557557
elseif g:EasyGrepRoot == "cwd"
@@ -725,34 +725,14 @@ function! s:ApplySearchDirectoriesToFileTargetList(fileTargets)
725725
let fileTargets = a:fileTargets
726726

727727
" Build a list of the directories in buffers
728-
let dirs = s:GetBufferDirsList()
729-
730-
let newlst = copy(fileTargets)
728+
let dirs = s:GetDirectorySearchList()
731729

732-
let root = s:GetGrepRoot()
733-
let currDir = s:GetCwdEscaped()
734-
let accepteddirs = [ root ]
730+
let newlst = []
735731
for dir in dirs
736-
let addToList = 1
737-
if dir == '.'
738-
let dir = currDir
739-
endif
740-
if dir == root
741-
let addToList = 0
742-
elseif s:IsRecursiveSearch()
743-
for d in accepteddirs
744-
if s:IsRecursivelyReachable(d, dir)
745-
let addToList = 0
746-
break
747-
endif
748-
endfor
749-
endif
750-
if addToList
751-
call add(accepteddirs, dir)
752-
for p in fileTargets
753-
call add(newlst, dir."/".p)
754-
endfor
755-
endif
732+
for target in fileTargets
733+
let newTarget = dir == "." ? target : dir."/".target
734+
call add(newlst, newTarget)
735+
endfor
756736
endfor
757737

758738
return newlst
@@ -819,7 +799,8 @@ function! s:GetDirectorySearchList()
819799
endfor
820800
endif
821801
if addToList
822-
call add(bufferSetList, s:FileEscape(dir))
802+
let escapedDir = s:FileEscape(dir)
803+
call add(bufferSetList, escapedDir)
823804
endif
824805
let i += 1
825806
endwhile
@@ -1060,6 +1041,7 @@ function! <sid>EchoGrepCommand()
10601041
let dirs = s:GetDirectorySearchList()
10611042
let dirAnnotation = "Search Directory: "
10621043
for d in dirs
1044+
let d = (d == ".") ? d." --> ".s:GetCwdEscaped()."" : d
10631045
call s:Echo(dirAnnotation.d)
10641046
let dirAnnotation = "Additional Directory: "
10651047
endfor

0 commit comments

Comments
 (0)