To: vim_dev@googlegroups.com Subject: Patch 8.2.2487 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2487 Problem: Terminal shows garbage after double-wide character with a combining character. (Kyoichiro Yamada) Solution: Libvterm: do not add the width of the combining character to the glyph width. (closes #7801) Files: src/libvterm/src/state.c, src/testdir/test_terminal.vim, src/testdir/dumps/Test_terminal_combining.dump *** ../vim-8.2.2486/src/libvterm/src/state.c 2020-06-27 18:13:04.962631936 +0200 --- src/libvterm/src/state.c 2021-02-08 21:01:22.705869230 +0100 *************** *** 133,139 **** if(rect.start_col == 0 && rect.end_col == state->cols && rightward == 0) { int height = rect.end_row - rect.start_row - abs(downward); int row; ! VTermLineInfo zeroLineInfo = { 0 }; if(downward > 0) { memmove(state->lineinfo + rect.start_row, --- 133,139 ---- if(rect.start_col == 0 && rect.end_col == state->cols && rightward == 0) { int height = rect.end_row - rect.start_row - abs(downward); int row; ! VTermLineInfo zeroLineInfo = {0x0}; if(downward > 0) { memmove(state->lineinfo + rect.start_row, *************** *** 384,390 **** abort(); } #endif ! width += this_width; } chars[glyph_ends - glyph_starts] = 0; --- 384,391 ---- abort(); } #endif ! if (i == glyph_starts || this_width > width) ! width = this_width; } chars[glyph_ends - glyph_starts] = 0; *************** *** 1813,1819 **** } for( ; row < rows; row++) { ! VTermLineInfo lineInfo = {0}; newlineinfo[row] = lineInfo; } --- 1814,1820 ---- } for( ; row < rows; row++) { ! VTermLineInfo lineInfo = {0x0}; newlineinfo[row] = lineInfo; } *** ../vim-8.2.2486/src/testdir/test_terminal.vim 2020-11-24 19:36:12.718255326 +0100 --- src/testdir/test_terminal.vim 2021-02-08 21:25:03.750139756 +0100 *************** *** 965,971 **** call assert_equal("b", l[1].chars) call assert_equal("c", l[2].chars) ! " multibyte + composing let txt = "\u304b\u3099\u304e\u304f\u3099\u3052\u3053\u3099" call term_sendkeys(buf, "echo " . txt) call TermWait(buf, 25) --- 965,971 ---- call assert_equal("b", l[1].chars) call assert_equal("c", l[2].chars) ! " multibyte + composing: がぎぐげご let txt = "\u304b\u3099\u304e\u304f\u3099\u3052\u3053\u3099" call term_sendkeys(buf, "echo " . txt) call TermWait(buf, 25) *************** *** 974,983 **** call WaitForAssert({-> assert_equal(txt, term_getline(buf, lnum[1] + 1))}, 1000) let l = term_scrape(buf, lnum[1] + 1) call assert_equal("\u304b\u3099", l[0].chars) ! call assert_equal("\u304e", l[2].chars) ! call assert_equal("\u304f\u3099", l[3].chars) ! call assert_equal("\u3052", l[5].chars) ! call assert_equal("\u3053\u3099", l[6].chars) " \u00a0 + composing let txt = "abc\u00a0\u0308" --- 974,988 ---- call WaitForAssert({-> assert_equal(txt, term_getline(buf, lnum[1] + 1))}, 1000) let l = term_scrape(buf, lnum[1] + 1) call assert_equal("\u304b\u3099", l[0].chars) ! call assert_equal(2, l[0].width) ! call assert_equal("\u304e", l[1].chars) ! call assert_equal(2, l[1].width) ! call assert_equal("\u304f\u3099", l[2].chars) ! call assert_equal(2, l[2].width) ! call assert_equal("\u3052", l[3].chars) ! call assert_equal(2, l[3].width) ! call assert_equal("\u3053\u3099", l[4].chars) ! call assert_equal(2, l[4].width) " \u00a0 + composing let txt = "abc\u00a0\u0308" *************** *** 1244,1249 **** --- 1249,1274 ---- call delete('Xopenterm') endfunc + func Test_combining_double_width() + CheckUnix + CheckRunVimInTerminal + + call writefile(["\xe3\x83\x9b\xe3\x82\x9a"], 'Xonedouble') + let lines =<< trim END + call term_start(['/bin/sh', '-c', 'cat Xonedouble']) + END + call writefile(lines, 'Xcombining') + let buf = RunVimInTerminal('-S Xcombining', #{rows: 9}) + + " this opens a window, incsearch should not use the old cursor position + call VerifyScreenDump(buf, 'Test_terminal_combining', {}) + call term_sendkeys(buf, ":q\") + + call StopVimInTerminal(buf) + call delete('Xonedouble') + call delete('Xcombining') + endfunc + func Test_terminal_popup_with_cmd() " this was crashing let buf = term_start(&shell, #{hidden: v:true}) *** ../vim-8.2.2486/src/testdir/dumps/Test_terminal_combining.dump 2021-02-08 21:28:21.273538408 +0100 --- src/testdir/dumps/Test_terminal_combining.dump 2021-02-08 21:02:47.137729151 +0100 *************** *** 0 **** --- 1,9 ---- + >ポ*0&#ffffff0| +&@72 + |~+0#4040ff13&| @73 + |~| @73 + |!+2#ffffff16#00e0003|/|b|i|n|/|s|h| |[|f|i|n|i|s|h|e|d|]| @37|1|,|1| @11|A|l@1 + | +0#0000000#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 + | +0&&@74 *** ../vim-8.2.2486/src/version.c 2021-02-07 18:06:25.266692335 +0100 --- src/version.c 2021-02-08 20:50:36.630123725 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2487, /**/ -- Have you heard about the new Barbie doll? It's called Divorce Barbie. It comes with most of Ken's stuff. /// 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 ///