wordcount: check that the retun value has the dict key

else it will throw an error.
This commit is contained in:
Christian Brabandt 2018-09-21 11:49:05 +02:00
parent 11e6492849
commit ecf10d0e58
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
1 changed files with 5 additions and 1 deletions

View File

@ -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)