]> granicus.if.org Git - vim/commitdiff
patch 8.2.2487: terminal shows garbage after double-wide character v8.2.2487
authorBram Moolenaar <Bram@vim.org>
Mon, 8 Feb 2021 20:29:48 +0000 (21:29 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 8 Feb 2021 20:29:48 +0000 (21:29 +0100)
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)

src/libvterm/src/state.c
src/testdir/dumps/Test_terminal_combining.dump [new file with mode: 0644]
src/testdir/test_terminal.vim
src/version.c

index 390aa8dce4d8ea702ba3eca1086c548b38b2350f..afb188c7e2023aa6f2750b6d68c0b78b8ce6e5bf 100644 (file)
@@ -384,7 +384,8 @@ static int on_text(const char bytes[], size_t len, void *user)
         abort();
       }
 #endif
-      width += this_width;
+      if (i == glyph_starts || this_width > width)
+       width = this_width;
     }
 
     chars[glyph_ends - glyph_starts] = 0;
diff --git a/src/testdir/dumps/Test_terminal_combining.dump b/src/testdir/dumps/Test_terminal_combining.dump
new file mode 100644 (file)
index 0000000..390da0a
--- /dev/null
@@ -0,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
index 8d47c0886c0fce738ab14edd138e6a90ff2ccb28..90241710ec5a44b784f669ce633e6a9ee80e4f06 100644 (file)
@@ -965,7 +965,7 @@ func Test_terminal_composing_unicode()
   call assert_equal("b", l[1].chars)
   call assert_equal("c", l[2].chars)
 
-  " multibyte + composing
+  " multibyte + composing: がぎぐげご
   let txt = "\u304b\u3099\u304e\u304f\u3099\u3052\u3053\u3099"
   call term_sendkeys(buf, "echo " . txt)
   call TermWait(buf, 25)
@@ -974,10 +974,15 @@ func Test_terminal_composing_unicode()
   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)
+  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,6 +1249,26 @@ func Test_open_term_from_cmd()
   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\<CR>")
+
+  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})
index e203038df71a3450362fadd4e2d57b80352b3cdb..d07c0e3eecfe640b0ab044ed9678abc55a31c2ff 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2487,
 /**/
     2486,
 /**/