Skip to content

Commit 919f716

Browse files
committed
extract and refactor show_result function
1 parent 10a5f63 commit 919f716

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

autoload/codequery/query.vim

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ function! s:create_grep_options(word) abort
5050
endfunction
5151

5252

53+
function! s:show_result() abort
54+
let results = getqflist()
55+
call codequery#query#prettify_qf_layout_and_map_keys(results)
56+
if !empty(results)
57+
echom 'Found ' . len(results) . ' result' . (len(results) > 1 ? 's' : '')
58+
else
59+
echom 'Result Not Found'
60+
endif
61+
endfunction
62+
63+
5364

5465
" =============================================================================
5566
" Entries
@@ -193,14 +204,7 @@ function! codequery#query#do_query(word) abort
193204
let &l:grepprg = grepprg . ' \| awk "{ sub(/.*\/\.\//,x) }1"'
194205
silent execute grepcmd
195206
redraw!
196-
197-
let results = getqflist()
198-
call codequery#query#prettify_qf_layout_and_map_keys(results)
199-
if !empty(results)
200-
echom 'Found ' . len(results) . ' results'
201-
else
202-
echom 'Result Not Found'
203-
endif
207+
call s:show_result()
204208
finally
205209
let &l:grepprg = l:grepprg_bak
206210
let &grepformat = l:grepformat_bak

0 commit comments

Comments
 (0)