Skip to content

Commit f138728

Browse files
committed
patch 8.2.2640: screenstring() returns non-existing composing characters
Problem: screenstring() returns non-existing composing characters. Solution: Only use composing characters if there is a base character.
1 parent 5ea79a2 commit f138728

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7902,7 +7902,7 @@ f_screenstring(typval_T *argvars, typval_T *rettv)
79027902
c = ScreenLines[off];
79037903
buflen += mb_char2bytes(c, buf);
79047904

7905-
if (enc_utf8)
7905+
if (enc_utf8 && ScreenLinesUC[off] != 0)
79067906
for (i = 0; i < Screen_mco && ScreenLinesC[i][off] != 0; ++i)
79077907
buflen += mb_char2bytes(ScreenLinesC[i][off], buf + buflen);
79087908

src/testdir/test_listchars.vim

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func Test_listchars()
146146
set list
147147
" Non-breaking space
148148
let nbsp = nr2char(0xa0)
149-
call append(0, [ ">".nbsp."<" ])
149+
call append(0, [ ">" .. nbsp .. "<" ])
150150

151151
let expected = '>X< '
152152

@@ -193,12 +193,8 @@ func Test_listchars_unicode()
193193
set list
194194

195195
let nbsp = nr2char(0xa0)
196-
call append(0, [
197-
\ "a\tb c".nbsp."d"
198-
\ ])
199-
let expected = [
200-
\ 'a←↔↔↔↔↔→b␣c≠d⇔'
201-
\ ]
196+
call append(0, ["a\tb c" .. nbsp .. "d"])
197+
let expected = ['a←↔↔↔↔↔→b␣c≠d⇔']
202198
redraw!
203199
call cursor(1, 1)
204200
call assert_equal(expected, ScreenLines(1, virtcol('$')))
@@ -221,10 +217,10 @@ func Test_listchars_composing()
221217
let nbsp1 = nr2char(0xa0)
222218
let nbsp2 = nr2char(0x202f)
223219
call append(0, [
224-
\ " \u3099\t \u309A".nbsp1.nbsp1."\u0302".nbsp2.nbsp2."\u0302",
220+
\ " \u3099\t \u309A" .. nbsp1 .. nbsp1 .. "\u0302" .. nbsp2 .. nbsp2 .. "\u0302",
225221
\ ])
226222
let expected = [
227-
\ "_ \u3099^I \u309A=".nbsp1."\u0302=".nbsp2."\u0302$"
223+
\ "_ \u3099^I \u309A=" .. nbsp1 .. "\u0302=" .. nbsp2 .. "\u0302$"
228224
\ ]
229225
redraw!
230226
call cursor(1, 1)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2640,
753755
/**/
754756
2639,
755757
/**/

0 commit comments

Comments
 (0)