Fortune: handle multibyte characters
This commit is contained in:
parent
89bf0a5c24
commit
f3044c7f52
2 changed files with 3 additions and 3 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue