wordcount: check that the retun value has the dict key
else it will throw an error.
This commit is contained in:
parent
11e6492849
commit
ecf10d0e58
|
@ -7,7 +7,11 @@ scriptencoding utf-8
|
||||||
if exists('*wordcount')
|
if exists('*wordcount')
|
||||||
function! s:get_wordcount(visual_mode_active)
|
function! s:get_wordcount(visual_mode_active)
|
||||||
let query = a:visual_mode_active ? 'visual_words' : 'words'
|
let query = a:visual_mode_active ? 'visual_words' : 'words'
|
||||||
return string(wordcount()[query])
|
let result = wordcount()
|
||||||
|
if has_key(result, query)
|
||||||
|
return string(result[query])
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:get_wordcount(visual_mode_active)
|
function! s:get_wordcount(visual_mode_active)
|
||||||
|
|
Loading…
Reference in New Issue