From f3044c7f525e2e8d43bf2ae91ff687b2bbfb10e9 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 11 Jan 2017 12:57:33 +0100 Subject: [PATCH] Fortune: handle multibyte characters --- autoload/startify/fortune.vim | 4 ++-- doc/startify.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/startify/fortune.vim b/autoload/startify/fortune.vim index 45ce8df..8526f69 100644 --- a/autoload/startify/fortune.vim +++ b/autoload/startify/fortune.vim @@ -126,7 +126,7 @@ endfunction " Function: s:draw_box {{{1 function! s:draw_box(lines) abort - let longest_line = max(map(copy(a:lines), 'len(v:val)')) + let longest_line = max(map(copy(a:lines), 'strwidth(v:val)')) if &encoding == 'utf-8' && get(g:, 'startify_fortune_use_unicode') let top_left_corner = '╭' let top_right_corner = '╮' @@ -146,7 +146,7 @@ function! s:draw_box(lines) abort let bottom = bottom_left_corner . repeat(top_bottom_side, longest_line + 2) . bottom_right_corner let lines = [top] for l in a:lines - let offset = longest_line - len(l) + let offset = longest_line - strwidth(l) let lines += [side . ' '. l . repeat(' ', offset) .' ' . side] endfor let lines += [bottom] diff --git a/doc/startify.txt b/doc/startify.txt index aa1384a..2889289 100644 --- a/doc/startify.txt +++ b/doc/startify.txt @@ -838,7 +838,7 @@ How do I center my header/footer?~ Try something along these lines: > function! s:filter_header(lines) abort - let longest_line = max(map(copy(a:lines), 'len(v:val)')) + let longest_line = max(map(copy(a:lines), 'strwidth(v:val)')) let centered_lines = map(copy(a:lines), \ 'repeat(" ", (&columns / 2) - (longest_line / 2)) . v:val') return centered_lines