diff --git a/autoload/airline/extensions/wordcount.vim b/autoload/airline/extensions/wordcount.vim index ad0a72e..a25d100 100644 --- a/autoload/airline/extensions/wordcount.vim +++ b/autoload/airline/extensions/wordcount.vim @@ -7,13 +7,19 @@ let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default') function! s:update() if match(&ft, s:filetypes) > -1 - if get(b:, 'airline_wordcount_cache', '') is# '' || - \ b:airline_wordcount_cache isnot# get(b:, 'airline_wordcount', '') || - \ get(b:, 'airline_change_tick', 0) != b:changedtick - " cache data + let l:mode = mode() + if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S' let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format() - let b:airline_wordcount_cache = b:airline_wordcount let b:airline_change_tick = b:changedtick + else + if get(b:, 'airline_wordcount_cache', '') is# '' || + \ b:airline_wordcount_cache isnot# get(b:, 'airline_wordcount', '') || + \ get(b:, 'airline_change_tick', 0) != b:changedtick + " cache data + let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format() + let b:airline_wordcount_cache = b:airline_wordcount + let b:airline_change_tick = b:changedtick + endif endif endif endfunction diff --git a/autoload/airline/extensions/wordcount/formatters/default.vim b/autoload/airline/extensions/wordcount/formatters/default.vim index 4a5eae8..8f1293f 100644 --- a/autoload/airline/extensions/wordcount/formatters/default.vim +++ b/autoload/airline/extensions/wordcount/formatters/default.vim @@ -18,7 +18,17 @@ endfunction function! s:wordcount() if exists("*wordcount") - return wordcount()['words'] + let l:mode = mode() + if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S' + let l:visual_words = wordcount()['visual_words'] + if l:visual_words != '' + return l:visual_words + else + return 0 + endif + else + return wordcount()['words'] + endif elseif mode() =~? 's' return else @@ -41,7 +51,7 @@ endfunction function s:get_decimal_group() if match(v:lang, '\v\cC|en') > -1 return ',' - elseif match(v:lang, '\v\cde|dk|fr') > -1 + elseif match(v:lang, '\v\cde|dk|fr|pt') > -1 return '.' endif return ''