To: vim_dev@googlegroups.com Subject: Patch 8.1.1655 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1655 Problem: Popup window border drawn wrong with multi-byte char. (Marcin Szamotulski) Solution: Correct check in mb_fix_col(). (closes #4635) Files: src/mbyte.c, src/testdir/test_popupwin.vim, testdir/dumps/Test_popupwin_24.dump *** ../vim-8.1.1654/src/mbyte.c 2019-07-07 19:16:54.286128604 +0200 --- src/mbyte.c 2019-07-08 23:25:07.455923144 +0200 *************** *** 4266,4279 **** int mb_fix_col(int col, int row) { col = check_col(col); row = check_row(row); if (has_mbyte && ScreenLines != NULL && col > 0 && ((enc_dbcs ! && ScreenLines[LineOffset[row] + col] != NUL && dbcs_screen_head_off(ScreenLines + LineOffset[row], ! ScreenLines + LineOffset[row] + col)) ! || (enc_utf8 && ScreenLines[LineOffset[row] + col] == 0))) return col - 1; return col; } --- 4266,4283 ---- 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[off] != NUL && dbcs_screen_head_off(ScreenLines + LineOffset[row], ! ScreenLines + off)) ! || (enc_utf8 && ScreenLines[off] == 0 ! && ScreenLinesUC[off] == 0))) return col - 1; return col; } *** ../vim-8.1.1654/src/testdir/test_popupwin.vim 2019-07-07 18:27:52.365277132 +0200 --- src/testdir/test_popupwin.vim 2019-07-08 23:22:58.424531721 +0200 *************** *** 113,118 **** --- 113,121 ---- 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,127 **** --- 125,136 ---- 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') *** ../vim-8.1.1654/src/testdir/dumps/Test_popupwin_24.dump 2019-07-08 23:29:46.870662886 +0200 --- src/testdir/dumps/Test_popupwin_24.dump 2019-07-08 23:23:10.648473967 +0200 *************** *** 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| *** ../vim-8.1.1654/src/version.c 2019-07-08 22:23:30.574768870 +0200 --- src/version.c 2019-07-08 23:28:52.974863706 +0200 *************** *** 779,780 **** --- 779,782 ---- { /* Add new patch number below this line */ + /**/ + 1655, /**/ -- Windows M!uqoms /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///