]> granicus.if.org Git - vim/commitdiff
patch 8.2.2640: screenstring() returns non-existing composing characters v8.2.2640
authorBram Moolenaar <Bram@vim.org>
Mon, 22 Mar 2021 16:11:15 +0000 (17:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 22 Mar 2021 16:11:15 +0000 (17:11 +0100)
Problem:    screenstring() returns non-existing composing characters.
Solution:   Only use composing characters if there is a base character.

src/evalfunc.c
src/testdir/test_listchars.vim
src/version.c

index 8fcdedbc0081741c9a03108843f623a7e0cf9997..6db93b86ea136dcf5bd9379e41f32bd20b58a7ba 100644 (file)
@@ -7902,7 +7902,7 @@ f_screenstring(typval_T *argvars, typval_T *rettv)
        c = ScreenLines[off];
     buflen += mb_char2bytes(c, buf);
 
-    if (enc_utf8)
+    if (enc_utf8 && ScreenLinesUC[off] != 0)
        for (i = 0; i < Screen_mco && ScreenLinesC[i][off] != 0; ++i)
            buflen += mb_char2bytes(ScreenLinesC[i][off], buf + buflen);
 
index 172407a8da513080f79e6eda1868d3fa7765e90d..9aca080ddd0486435d02c85d19b4dfa4d27ed9af 100644 (file)
@@ -146,7 +146,7 @@ func Test_listchars()
   set list
   " Non-breaking space
   let nbsp = nr2char(0xa0)
-  call append(0, [ ">".nbsp."<" ])
+  call append(0, [ ">" .. nbsp .. "<" ])
 
   let expected = '>X< '
 
@@ -193,12 +193,8 @@ func Test_listchars_unicode()
   set list
 
   let nbsp = nr2char(0xa0)
-  call append(0, [
-        \ "a\tb c".nbsp."d"
-        \ ])
-  let expected = [
-        \ 'a←↔↔↔↔↔→b␣c≠d⇔'
-        \ ]
+  call append(0, ["a\tb c" .. nbsp .. "d"])
+  let expected = ['a←↔↔↔↔↔→b␣c≠d⇔']
   redraw!
   call cursor(1, 1)
   call assert_equal(expected, ScreenLines(1, virtcol('$')))
@@ -221,10 +217,10 @@ func Test_listchars_composing()
   let nbsp1 = nr2char(0xa0)
   let nbsp2 = nr2char(0x202f)
   call append(0, [
-        \ "  \u3099\t \u309A".nbsp1.nbsp1."\u0302".nbsp2.nbsp2."\u0302",
+        \ "  \u3099\t \u309A" .. nbsp1 .. nbsp1 .. "\u0302" .. nbsp2 .. nbsp2 .. "\u0302",
         \ ])
   let expected = [
-        \ "_ \u3099^I \u309A=".nbsp1."\u0302=".nbsp2."\u0302$"
+        \ "_ \u3099^I \u309A=" .. nbsp1 .. "\u0302=" .. nbsp2 .. "\u0302$"
         \ ]
   redraw!
   call cursor(1, 1)
index e2519f4d42d09ebacb86b6647a22d0f0a2267f05..2c52166d69567d24bafced3b258049efaf8f5a84 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2640,
 /**/
     2639,
 /**/