Skip to content

Commit 467f282

Browse files
committed
Add 'search' option to GrepRoot
1 parent f0bfcc8 commit 467f282

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

plugin/EasyGrep.vim

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,12 @@ function! s:SetGrepRoot(...)
470470
else
471471
let lst = [ "Select grep root: " ]
472472
call extend(lst, [ "1. 'cwd' (search from the current directory)" ])
473-
call extend(lst, [ "2. 'repository' (alias for '".s:EasyGrepRepositoryList."')" ])
474-
call extend(lst, [ "3. A specific directory" ])
473+
call extend(lst, [ "2. 'search' (search from a dynamic root)" ])
474+
call extend(lst, [ "3. 'repository' (alias for '".s:EasyGrepRepositoryList."')" ])
475+
call extend(lst, [ "4. 'directory' (search from a specific directory)" ])
475476

476-
let numFixedItems = 3
477-
let upperLimit = 4
477+
let numFixedItems = 4
478+
let upperLimit = numFixedItems + 1
478479
if exists("s:EasyGrepRootHistory")
479480
let numAdditional = len(s:EasyGrepRootHistory)
480481
for dir in s:EasyGrepRootHistory
@@ -490,8 +491,14 @@ function! s:SetGrepRoot(...)
490491
elseif grepRootNumChoice == 1
491492
let grepRootChoice = "cwd"
492493
elseif grepRootNumChoice == 2
493-
let grepRootChoice = "repository"
494+
let grepRootChoice = input("Enter a pattern for the dynamic root (comma separated): ", "")
495+
if empty(grepRootChoice)
496+
return
497+
endif
498+
let grepRootChoice = "search:".grepRootChoice
494499
elseif grepRootNumChoice == 3
500+
let grepRootChoice = "repository"
501+
elseif grepRootNumChoice == 4
495502
let grepRootChoice = input("Enter a directory to set the root to: ", "", "dir")
496503
if empty(grepRootChoice)
497504
return
@@ -593,7 +600,7 @@ function! s:GetGrepRootEx()
593600
elseif isdirectory(g:EasyGrepRoot)
594601
" Trim a trailing slash
595602
let g:EasyGrepRoot = substitute(g:EasyGrepRoot, "/$", "", "")
596-
let fullRootPath = fnamemodify(g:EasyGrepRoot, ":p")
603+
let fullRootPath = substitute(fnamemodify(g:EasyGrepRoot, ":p"), "/$", "", "")
597604
if g:EasyGrepRoot[0] == '/' && g:EasyGrepRoot != fullRootPath
598605
let g:EasyGrepRoot = fullRootPath
599606
elseif match(g:EasyGrepRoot, "\\./", 0) != 0 && g:EasyGrepRoot != fullRootPath
@@ -606,7 +613,7 @@ function! s:GetGrepRootEx()
606613
endif
607614

608615
if !empty(errorstring)
609-
call s:Error(errorstring." for g:EasyGrepRoot '".g:EasyGrepRoot."'; acking as if cwd")
616+
call s:Error(errorstring." for g:EasyGrepRoot '".g:EasyGrepRoot."'; acting as if cwd")
610617
endif
611618
call s:Log("GetGrepRootEx returned ".pathtoreturn)
612619
return [pathtoreturn, empty(errorstring), type]

0 commit comments

Comments
 (0)