searchcount: Ignore errors from searchcount() function
If the search regex causes an error, an ugly error message is thrown, so ignore errors in that case silently. closes #2216
This commit is contained in:
parent
ef4666bd86
commit
3a55368320
|
@ -18,22 +18,26 @@ function! airline#extensions#searchcount#apply(...) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#searchcount#status() abort
|
function! airline#extensions#searchcount#status() abort
|
||||||
let result = searchcount(#{recompute: 1, maxcount: -1})
|
try
|
||||||
if empty(result) || result.total ==# 0
|
let result = searchcount(#{recompute: 1, maxcount: -1})
|
||||||
return ''
|
if empty(result) || result.total ==# 0
|
||||||
endif
|
return ''
|
||||||
if result.incomplete ==# 1 " timed out
|
|
||||||
return printf(' /%s [?/??]', @/)
|
|
||||||
elseif result.incomplete ==# 2 " max count exceeded
|
|
||||||
if result.total > result.maxcount &&
|
|
||||||
\ result.current > result.maxcount
|
|
||||||
return printf('%s[>%d/>%d]', @/,
|
|
||||||
\ result.current, result.total)
|
|
||||||
elseif result.total > result.maxcount
|
|
||||||
return printf('%s[%d/>%d]', @/,
|
|
||||||
\ result.current, result.total)
|
|
||||||
endif
|
endif
|
||||||
endif
|
if result.incomplete ==# 1 " timed out
|
||||||
return printf('%s[%d/%d]', @/,
|
return printf(' /%s [?/??]', @/)
|
||||||
\ result.current, result.total)
|
elseif result.incomplete ==# 2 " max count exceeded
|
||||||
|
if result.total > result.maxcount &&
|
||||||
|
\ result.current > result.maxcount
|
||||||
|
return printf('%s[>%d/>%d]', @/,
|
||||||
|
\ result.current, result.total)
|
||||||
|
elseif result.total > result.maxcount
|
||||||
|
return printf('%s[%d/>%d]', @/,
|
||||||
|
\ result.current, result.total)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return printf('%s[%d/%d]', @/,
|
||||||
|
\ result.current, result.total)
|
||||||
|
catch
|
||||||
|
return ''
|
||||||
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
Loading…
Reference in New Issue