Skip to content

Commit 32236a8

Browse files
authored
Merge pull request #336 from hiberabyss/update
support CtrlSFUpdate override search options
2 parents 5ef6035 + 56247e1 commit 32236a8

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

autoload/ctrlsf.vim

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ let s:current_query = ''
1717
"
1818
" Basic process: query, parse, render and display.
1919
"
20-
func! s:ExecSearch(args) abort
20+
func! s:ExecSearch(args, override = v:false) abort
2121
" reset all states
22-
call s:Reset()
22+
23+
call s:Reset(a:override)
2324

2425
try
25-
call ctrlsf#opt#ParseOptions(a:args)
26+
call ctrlsf#opt#ParseOptions(a:args, a:override)
2627
catch /ParseOptionsException/
2728
return -1
2829
endtry
@@ -43,9 +44,11 @@ endf
4344
"
4445
" Reset all states of many modules
4546
"
46-
func! s:Reset() abort
47+
func! s:Reset(override) abort
4748
call ctrlsf#db#Reset()
48-
call ctrlsf#opt#Reset()
49+
if !a:override
50+
call ctrlsf#opt#Reset()
51+
endif
4952
call ctrlsf#win#Reset()
5053
call ctrlsf#view#Reset()
5154
call ctrlsf#async#Reset()
@@ -164,11 +167,11 @@ endf
164167

165168
" Update()
166169
"
167-
func! ctrlsf#Update() abort
170+
func! ctrlsf#Update(args) abort
168171
if empty(s:current_query)
169172
return -1
170173
endif
171-
call s:ExecSearch(s:current_query)
174+
call s:ExecSearch(a:args, v:true)
172175
endf
173176

174177
" Open()

autoload/ctrlsf/opt.vim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,20 @@ func! s:ParseOptions(options_str) abort
313313
return options
314314
endf
315315

316+
function! ctrlsf#opt#Options()
317+
return s:options
318+
endfunction
319+
316320
" ParseOptions()
317321
"
318-
func! ctrlsf#opt#ParseOptions(options_str) abort
319-
let s:options = s:ParseOptions(a:options_str)
322+
func! ctrlsf#opt#ParseOptions(options_str, override = v:false) abort
323+
let opts = s:ParseOptions(a:options_str)
324+
325+
if a:override
326+
call extend(s:options, opts, 'force')
327+
else
328+
let s:options = opts
329+
endif
320330

321331
" derivative options
322332

doc/ctrlsf.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ mode:
155155
If CtrlSF window is closed (by <q> or |:CtrlSFClose|), reopen it. If the
156156
window is already on display, then focus it.
157157

158-
:CtrlSFUpdate *:CtrlSFUpdate*
158+
:CtrlSFUpdate [arguments] {pattern} [path] ... *:CtrlSFUpdate*
159159

160-
Update CtrlSF result by invoking a new search with same arguments and pattern
161-
of last one.
160+
If no arguments, update CtrlSF result by invoking a new search with same
161+
arguments and pattern of last one. Otherwise, will override last search
162+
arguments and do the search.
162163

163164
:CtrlSFClose *:CtrlSFClose*
164165

plugin/ctrlsf.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ endif
321321
com! -n=* -comp=customlist,ctrlsf#comp#Completion CtrlSF call ctrlsf#Search(<q-args>)
322322
com! -n=* -comp=customlist,ctrlsf#comp#Completion CtrlSFQuickfix call ctrlsf#Quickfix(<q-args>)
323323
com! -n=0 CtrlSFOpen call ctrlsf#Open()
324-
com! -n=0 CtrlSFUpdate call ctrlsf#Update()
324+
com! -n=* -comp=customlist,ctrlsf#comp#Completion CtrlSFUpdate call ctrlsf#Update(<q-args>)
325325
com! -n=0 CtrlSFClose call ctrlsf#Quit()
326326
com! -n=0 CtrlSFClearHL call ctrlsf#ClearSelectedLine()
327327
com! -n=0 CtrlSFToggle call ctrlsf#Toggle()

0 commit comments

Comments
 (0)