Skip to content

Commit 86efb1a

Browse files
committed
Add isselffiltering command paramter
1 parent a5e169b commit 86efb1a

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

plugin/EasyGrep.vim

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function! s:IsRecursiveSearch()
261261
return !s:IsModeBuffers()
262262
endif
263263
let commandParams = s:GetGrepCommandParameters()
264-
return has_key(commandParams, "isinherentlyrecursive") && (commandParams["isinherentlyrecursive"] == 1)
264+
return has_key(commandParams, "isinherentlyrecursive") && (commandParams["isinherentlyrecursive"] == '1')
265265
endfunction
266266
" }}}
267267
" GetSavedName {{{
@@ -1021,7 +1021,8 @@ function! s:ActivateChoice(choice)
10211021
let selectedMode = s:EasyGrepModeMultipleChoice
10221022
endif
10231023

1024-
if s:IsCommandAck()
1024+
let commandParams = s:GetGrepCommandParameters()
1025+
if s:CommandHas("isselffiltering")
10251026
if selectedMode != s:EasyGrepModeAll && selectedMode != s:EasyGrepModeBuffers
10261027
call s:Error("Cannot activate '".s:GetModeName(selectedMode)."' mode when ".s:GetGrepProgramVarAndName().", as this grepprg implements its own filtering")
10271028
return
@@ -1919,10 +1920,10 @@ endfunction
19191920
" CheckGrepCommandForChanges {{{
19201921
function! s:CheckGrepCommandForChanges()
19211922
if &grepprg != s:LastSeenGrepprg
1922-
if s:IsCommandAck()
1923+
if s:CommandHas("isselffiltering")
19231924
if !s:IsModeAll() && !s:IsModeBuffers()
19241925
call s:Info("==================================================================================")
1925-
call s:Info("The 'grepprg' has changed to '".s:GetGrepCommandName()."' since last inspected")
1926+
call s:Info("The 'grepprg' has changed to '".s:GetGrepProgramName()."' since last inspected")
19261927
call s:Info("Switching to 'All' mode as the '".s:GetModeName(g:EasyGrepMode)."' mode is incompatible with this program")
19271928
call s:Info("==================================================================================")
19281929
call s:ForceGrepMode(s:EasyGrepModeAll)
@@ -2381,6 +2382,17 @@ function! s:IsCommandFindstr()
23812382
return !s:IsCommandVimgrep() && (s:GetGrepProgramName() == "findstr")
23822383
endfunction
23832384
"}}}
2385+
" CommandParameterMatches {{{
2386+
function! s:CommandParameterMatches(parameter, value)
2387+
let commandParams = s:GetGrepCommandParameters()
2388+
return has_key(commandParams, a:parameter) && (commandParams[a:parameter] == a:value)
2389+
endfunction
2390+
"}}}
2391+
" CommandHas {{{
2392+
function! s:CommandHas(parameter)
2393+
return s:CommandParameterMatches(a:parameter, '1')
2394+
endfunction
2395+
"}}}
23842396
" GetGrepCommandParameters {{{
23852397
function! s:GetGrepCommandParameters()
23862398

@@ -2401,6 +2413,7 @@ function! s:GetGrepCommandParameters()
24012413
\ 'errorsuppress': '',
24022414
\ 'directoryneedsbackslash': '0',
24032415
\ 'isinherentlyrecursive': '0',
2416+
\ 'isselffiltering': '0',
24042417
\ }
24052418
elseif s:IsCommandGrep()
24062419
return {
@@ -2419,6 +2432,7 @@ function! s:GetGrepCommandParameters()
24192432
\ 'errorsuppress': '-s',
24202433
\ 'directoryneedsbackslash': '0',
24212434
\ 'isinherentlyrecursive': '0',
2435+
\ 'isselffiltering': '0',
24222436
\ }
24232437
elseif s:IsCommandGitGrep()
24242438
return {
@@ -2437,6 +2451,7 @@ function! s:GetGrepCommandParameters()
24372451
\ 'errorsuppress': '',
24382452
\ 'directoryneedsbackslash': '0',
24392453
\ 'isinherentlyrecursive': '0',
2454+
\ 'isselffiltering': '0',
24402455
\ }
24412456
elseif s:IsCommandAck()
24422457
return {
@@ -2455,6 +2470,7 @@ function! s:GetGrepCommandParameters()
24552470
\ 'errorsuppress': '',
24562471
\ 'directoryneedsbackslash': '0',
24572472
\ 'isinherentlyrecursive': '1',
2473+
\ 'isselffiltering': '1',
24582474
\ }
24592475
elseif s:IsCommandPt()
24602476
return {
@@ -2473,6 +2489,7 @@ function! s:GetGrepCommandParameters()
24732489
\ 'errorsuppress': '',
24742490
\ 'directoryneedsbackslash': '0',
24752491
\ 'isinherentlyrecursive': '0',
2492+
\ 'isselffiltering': '0',
24762493
\ }
24772494
elseif s:IsCommandFindstr()
24782495
return {
@@ -2491,6 +2508,7 @@ function! s:GetGrepCommandParameters()
24912508
\ 'errorsuppress': '',
24922509
\ 'directoryneedsbackslash': '1',
24932510
\ 'isinherentlyrecursive': '0',
2511+
\ 'isselffiltering': '0',
24942512
\ }
24952513
endif
24962514
return {}

0 commit comments

Comments
 (0)