Skip to content

Commit 0a70769

Browse files
committed
Silence xolox#misc#async#periodic_callback() when request queue is empty
1 parent 9d1f006 commit 0a70769

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ from the source code of the miscellaneous scripts using the Python module
3838
<!-- Start of generated documentation -->
3939

4040
The documentation of the 92 functions below was extracted from
41-
19 Vim scripts on June 30, 2014 at 00:41.
41+
19 Vim scripts on June 30, 2014 at 02:45.
4242

4343
### Asynchronous Vim script evaluation
4444

autoload/xolox/misc/async.vim

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,24 @@ function! xolox#misc#async#periodic_callback() " {{{1
229229
" process the response.
230230
"
231231
" [CursorHold]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorHold
232-
let num_processed = 0
233-
call xolox#misc#msg#debug("vim-misc %s: Checking for asynchronous responses (%i responses not yet received) ..", g:xolox#misc#version, len(g:xolox#misc#async#requests))
234-
for unique_number in sort(keys(g:xolox#misc#async#requests))
235-
let request = g:xolox#misc#async#requests[unique_number]
236-
let temporary_file = get(request, 'temporary_file', '')
237-
if !empty(temporary_file) && getfsize(temporary_file) > 0
238-
try
239-
call xolox#misc#msg#debug("vim-misc %s: Found asynchronous response by %s in %s ..", g:xolox#misc#version, request['function'], temporary_file)
240-
call xolox#misc#async#callback_to_parent(xolox#misc#persist#load(temporary_file))
241-
let num_processed += 1
242-
finally
243-
call delete(temporary_file)
244-
endtry
245-
endif
246-
endfor
247-
call xolox#misc#msg#debug("vim-misc %s: Processed %i asynchronous responses (%i responses not yet received).", g:xolox#misc#version, num_processed, len(g:xolox#misc#async#requests))
232+
if !empty(g:xolox#misc#async#requests)
233+
let num_processed = 0
234+
call xolox#misc#msg#debug("vim-misc %s: Checking for asynchronous responses (%i responses not yet received) ..", g:xolox#misc#version, len(g:xolox#misc#async#requests))
235+
for unique_number in sort(keys(g:xolox#misc#async#requests))
236+
let request = g:xolox#misc#async#requests[unique_number]
237+
let temporary_file = get(request, 'temporary_file', '')
238+
if !empty(temporary_file) && getfsize(temporary_file) > 0
239+
try
240+
call xolox#misc#msg#debug("vim-misc %s: Found asynchronous response by %s in %s ..", g:xolox#misc#version, request['function'], temporary_file)
241+
call xolox#misc#async#callback_to_parent(xolox#misc#persist#load(temporary_file))
242+
let num_processed += 1
243+
finally
244+
call delete(temporary_file)
245+
endtry
246+
endif
247+
endfor
248+
call xolox#misc#msg#debug("vim-misc %s: Processed %i asynchronous responses (%i responses not yet received).", g:xolox#misc#version, num_processed, len(g:xolox#misc#async#requests))
249+
endif
248250
endfunction
249251

250252
" }}}1

doc/misc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ from the source code of the miscellaneous scripts using the Python module
167167
'vimdoctool.py' included in vim-tools [5].
168168

169169
The documentation of the 92 functions below was extracted from 19 Vim scripts
170-
on June 30, 2014 at 00:41.
170+
on June 30, 2014 at 02:45.
171171

172172
-------------------------------------------------------------------------------
173173
*misc-asynchronous-vim-script-evaluation*

0 commit comments

Comments
 (0)