summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-08 23:30:22 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-08 23:30:22 +0200
commit3dabd718f4b2d8e09de9e2ec73832620b91c2f79 (patch)
treed8dc80b5d6b1a718537d688fcf906418289f4212
parent8a7383b6d28be02413cf115d4b8ed1b44d60dd9f (diff)
patch 8.1.1655: popup window border drawn wrong with multi-byte charv8.1.1655
Problem: Popup window border drawn wrong with multi-byte char. (Marcin Szamotulski) Solution: Correct check in mb_fix_col(). (closes #4635)
-rw-r--r--src/mbyte.c10
-rw-r--r--src/testdir/dumps/Test_popupwin_24.dump12
-rw-r--r--src/testdir/test_popupwin.vim9
-rw-r--r--src/version.c2
4 files changed, 30 insertions, 3 deletions
diff --git a/src/mbyte.c b/src/mbyte.c
index 94adddf7ef..2b76400662 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -4266,14 +4266,18 @@ mb_lefthalve(int row, int col)
int
mb_fix_col(int col, int row)
{
+ int off;
+
col = check_col(col);
row = check_row(row);
+ off = LineOffset[row] + col;
if (has_mbyte && ScreenLines != NULL && col > 0
&& ((enc_dbcs
- && ScreenLines[LineOffset[row] + col] != NUL
+ && ScreenLines[off] != NUL
&& dbcs_screen_head_off(ScreenLines + LineOffset[row],
- ScreenLines + LineOffset[row] + col))
- || (enc_utf8 && ScreenLines[LineOffset[row] + col] == 0)))
+ ScreenLines + off))
+ || (enc_utf8 && ScreenLines[off] == 0
+ && ScreenLinesUC[off] == 0)))
return col - 1;
return col;
}
diff --git a/src/testdir/dumps/Test_popupwin_24.dump b/src/testdir/dumps/Test_popupwin_24.dump
new file mode 100644
index 0000000000..f5386c9542
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_24.dump
@@ -0,0 +1,12 @@
+>1+0&#ffffff0| @73
+|2| |╔+0&#5fd7ff255|═@11|╗| +0&#ffffff0@5|╔+0&#dadada255|═@11|╗+0&#8a8a8a255| +0&#ffffff0@5|x+0&#5fd7ff255@13| +0&#ffffff0@2|#+0&#5fd7ff255|x@11|#| +0&#ffffff0@1
+|3| |║+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|║+0#0000000#5fd7ff255| +0&#ffffff0@5|║+0&#a8a8a8255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|║+0#0000000#8a8a8a255| +0&#ffffff0@5|x+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|x+0#0000000#5fd7ff255| +0&#ffffff0@2|x+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|x+0#0000000#5fd7ff255| +0&#ffffff0@1
+|4| |╚+0&#5fd7ff255|═@11|╝| +0&#ffffff0@5|║+0&#a8a8a8255|a+0#0000001#ffd7ff255|n|d| |m|o|r|e| @3|║+0#0000000#8a8a8a255| +0&#ffffff0@5|x+0&#5fd7ff255|l+0#0000001#ffd7ff255|i|n|e|s| |o|n|l|y| @1|x+0#0000000#5fd7ff255| +0&#ffffff0@2|x+0&#5fd7ff255|w+0#0000001#ffd7ff255|i|t|h| |c|o|r|n|e|r|s|x+0#0000000#5fd7ff255| +0&#ffffff0@1
+|5| @20|╚+0&#585858255|═@11|╝| +0&#ffffff0@5|x+0&#5fd7ff255@13| +0&#ffffff0@2|#+0&#5fd7ff255|x@11|#| +0&#ffffff0@1
+|6| |e+0&#5fd7ff255|a@11|f| +0&#ffffff0@58
+|7| |d+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|b+0#0000000#5fd7ff255| +0&#ffffff0@5| +0&#5fd7ff255@13| +0&#ffffff0@38
+|8| |d+0&#5fd7ff255|w+0#0000001#ffd7ff255|i|t|h| |n|u|m|b|e|r|s|b+0#0000000#5fd7ff255| +0&#ffffff0@5| +0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r| +0#0000000#5fd7ff255| +0&#ffffff0@5|┌+0#0000001#ffd7ff255|─@4|┐| +0#0000000#ffffff0@25
+|9| |h+0&#5fd7ff255|c@11|g| +0&#ffffff0@5| +0&#5fd7ff255|j+0#0000001#ffd7ff255|u|s|t| |b|l|a|n|k|s| | +0#0000000#5fd7ff255| +0&#ffffff0@5|│+0#0000001#ffd7ff255|h|e|l@1|o|│| +0#0000000#ffffff0@25
+|1|0| @19| +0&#5fd7ff255@13| +0&#ffffff0@5|└+0#0000001#ffd7ff255|─@4|┘| +0#0000000#ffffff0@25
+|1@1| @72
+|:|c|a|l@1| |M|u|l|t|i|B|y|t|e|(|)| @39|1|,|1| @10|T|o|p|
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index f952a42fe7..0ec4f76004 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -113,6 +113,9 @@ func Test_popup_with_border_and_padding()
call popup_create(['hello border', 'with corners'], {'line': 2, 'col': 60, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': ['x', '#']})
let winid = popup_create(['hello border', 'with numbers'], {'line': 6, 'col': 3, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': ['0', '1', '2', '3', '4', '5', '6', '7']})
call popup_create(['hello border', 'just blanks'], {'line': 7, 'col': 23, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': [' ']})
+ func MultiByte()
+ call popup_create(['hello'], {'line': 8, 'col': 43, 'border': [], 'borderchars': ['─', '│', '─', '│', '┌', '┐', '┘', '└']})
+ endfunc
END
call writefile(lines, 'XtestPopupBorder')
let buf = RunVimInTerminal('-S XtestPopupBorder', {'rows': 12})
@@ -122,6 +125,12 @@ func Test_popup_with_border_and_padding()
call term_sendkeys(buf, ":call popup_setoptions(winid, {'borderchars': ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']})\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_23', {})
+ " check multi-byte border only with 'ambiwidth' single
+ if &ambiwidth == 'single'
+ call term_sendkeys(buf, ":call MultiByte()\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_24', {})
+ endif
+
call StopVimInTerminal(buf)
call delete('XtestPopupBorder')
diff --git a/src/version.c b/src/version.c
index d35560adc5..62b95579dc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1655,
+/**/
1654,
/**/
1653,