# HG changeset patch # User Bram Moolenaar # Date 1562622304 -7200 # Node ID 484424955bfa8d2fa311cec250abf28991e92e32 # Parent bfb4d8e3544df076c78d251c725a7ce44da71496 patch 8.1.1655: popup window border drawn wrong with multi-byte char commit https://github.com/vim/vim/commit/3dabd718f4b2d8e09de9e2ec73832620b91c2f79 Author: Bram Moolenaar Date: Mon Jul 8 23:30:22 2019 +0200 patch 8.1.1655: popup window border drawn wrong with multi-byte char Problem: Popup window border drawn wrong with multi-byte char. (Marcin Szamotulski) Solution: Correct check in mb_fix_col(). (closes #4635) diff --git a/src/mbyte.c b/src/mbyte.c --- 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 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_24.dump @@ -0,0 +1,12 @@ +>1+0&#ffffff0| @73 +|2| |╔+0fd7ff255|═@11|╗| +0&#ffffff0@5|╔+0&#dadada255|═@11|╗+0a8a8a255| +0&#ffffff0@5|x+0fd7ff255@13| +0&#ffffff0@2|#+0fd7ff255|x@11|#| +0&#ffffff0@1 +|3| |║+0fd7ff255|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+0fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|x+0#0000000#5fd7ff255| +0&#ffffff0@2|x+0fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|x+0#0000000#5fd7ff255| +0&#ffffff0@1 +|4| |╚+0fd7ff255|═@11|╝| +0&#ffffff0@5|║+0&#a8a8a8255|a+0#0000001#ffd7ff255|n|d| |m|o|r|e| @3|║+0#0000000#8a8a8a255| +0&#ffffff0@5|x+0fd7ff255|l+0#0000001#ffd7ff255|i|n|e|s| |o|n|l|y| @1|x+0#0000000#5fd7ff255| +0&#ffffff0@2|x+0fd7ff255|w+0#0000001#ffd7ff255|i|t|h| |c|o|r|n|e|r|s|x+0#0000000#5fd7ff255| +0&#ffffff0@1 +|5| @20|╚+0�|═@11|╝| +0&#ffffff0@5|x+0fd7ff255@13| +0&#ffffff0@2|#+0fd7ff255|x@11|#| +0&#ffffff0@1 +|6| |e+0fd7ff255|a@11|f| +0&#ffffff0@58 +|7| |d+0fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|b+0#0000000#5fd7ff255| +0&#ffffff0@5| +0fd7ff255@13| +0&#ffffff0@38 +|8| |d+0fd7ff255|w+0#0000001#ffd7ff255|i|t|h| |n|u|m|b|e|r|s|b+0#0000000#5fd7ff255| +0&#ffffff0@5| +0fd7ff255|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+0fd7ff255|c@11|g| +0&#ffffff0@5| +0fd7ff255|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| +0fd7ff255@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 --- 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']})\") call VerifyScreenDump(buf, 'Test_popupwin_23', {}) + " check multi-byte border only with 'ambiwidth' single + if &ambiwidth == 'single' + call term_sendkeys(buf, ":call MultiByte()\") + call VerifyScreenDump(buf, 'Test_popupwin_24', {}) + endif + call StopVimInTerminal(buf) call delete('XtestPopupBorder') diff --git a/src/version.c b/src/version.c --- 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,