[vim] Consider ambiwidth for border (#1861)

Close #1856
Close #1857
This commit is contained in:
Kyoichiro Yamada 2020-02-10 17:52:15 +09:00 committed by GitHub
parent 02c5e62efe
commit 001d116884

View File

@ -842,8 +842,12 @@ else
endif
function! s:popup(opts) abort
" Support ambiwidth == 'double'
let ambidouble = &ambiwidth == 'double' ? 2 : 1
" Size and position
let width = min([max([0, float2nr(&columns * a:opts.width)]), &columns])
let width += width % ambidouble
let height = min([max([0, float2nr(&lines * a:opts.height)]), &lines - has('nvim')])
let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height))
let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width))
@ -861,15 +865,15 @@ function! s:popup(opts) abort
endif
if style == 'horizontal'
let hor = repeat('─', width)
let hor = repeat('─', width / ambidouble)
let mid = repeat(' ', width)
let border = [hor] + repeat([mid], height - 2) + [hor]
let margin = 0
else
let edges = style == 'sharp' ? ['┌', '┐', '└', '┘'] : ['╭', '╮', '╰', '╯']
let bar = repeat('─', width - 2)
let bar = repeat('─', width / ambidouble - 2)
let top = edges[0] .. bar .. edges[1]
let mid = '│' .. repeat(' ', width - 2) .. '│'
let mid = '│' .. repeat(' ', width - 2 * ambidouble) .. '│'
let bot = edges[2] .. bar .. edges[3]
let border = [top] + repeat([mid], height - 2) + [bot]
let margin = 2