Skip to content

Commit b80004c

Browse files
committed
Make 'stop' value default to 0
This is done because we want buffering, which increases performance quite a lot, by default. But buffering means that we can't count matches, thus we disable buffering when a stop value greater than 0 is used.
1 parent e9004ce commit b80004c

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

doc/grepper.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ The prompt uses this mapping to toggle the |:Grepper-side| flag.
278278

279279
------------------------------------------------------------------------------
280280
*g:grepper.stop* >
281-
let g:grepper.stop = 5000
281+
let g:grepper.stop = 0
282282
<
283283
This limits the number of matches for asynchronous searches. Thus, the grep
284284
tool is terminated early when the given number is reached. All present matches
@@ -288,6 +288,10 @@ Chances are, if you have more than 5000 matches, you executed Grepper in a
288288
place with too many subdirectories or your search query was too general or
289289
both. This limits the impact of otherwise long-running processes.
290290

291+
NOTE: Any value greater than 0 automatically disables buffering and therefore
292+
reduces performance a bit. It is recommended not to set this, but to use
293+
|:Grepper-stop| on demand, instead.
294+
291295
------------------------------------------------------------------------------
292296
*g:grepper.append* >
293297
let g:grepper.append = 0

plugin/grepper.vim

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let s:defaults = {
2929
\ 'searchreg': 0,
3030
\ 'side': 0,
3131
\ 'side_cmd': 'vnew',
32-
\ 'stop': 5000,
32+
\ 'stop': 0,
3333
\ 'dir': 'cwd',
3434
\ 'prompt_mapping_tool': '<tab>',
3535
\ 'prompt_mapping_dir': '<c-d>',
@@ -931,14 +931,17 @@ function! s:run(flags)
931931
if exists('s:id')
932932
silent! call jobstop(s:id)
933933
endif
934+
let opts = {
935+
\ 'on_stdout': function('s:on_stdout_nvim'),
936+
\ 'on_stderr': function('s:on_stdout_nvim'),
937+
\ 'on_exit': function('s:on_exit'),
938+
\ }
939+
if !a:flags.stop
940+
let opts.stdout_buffered = 1
941+
let opts.stderr_buffered = 1
942+
endif
934943
try
935-
let s:id = jobstart(cmd, extend(options, {
936-
\ 'on_stdout': function('s:on_stdout_nvim'),
937-
\ 'on_stderr': function('s:on_stdout_nvim'),
938-
\ 'stdout_buffered': 1,
939-
\ 'stderr_buffered': 1,
940-
\ 'on_exit': function('s:on_exit'),
941-
\ }))
944+
let s:id = jobstart(cmd, extend(options, opts))
942945
finally
943946
call s:chdir_pop(orig_dir)
944947
endtry

0 commit comments

Comments
 (0)