From 001d1168848c0d799e69f4172eaeb79cce9f36c0 Mon Sep 17 00:00:00 2001 From: Kyoichiro Yamada Date: Mon, 10 Feb 2020 17:52:15 +0900 Subject: [PATCH] [vim] Consider ambiwidth for border (#1861) Close #1856 Close #1857 --- plugin/fzf.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 7e3046a..b024c92 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -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