if (has_mbyte)
{
- // change last character to '…'
+ char_u buf[MB_MAXBYTES + 1];
+ char_u *cp = buf;
+
+ // change the last character to '…', converted to the
+ // current 'encoding'
+ STRCPY(buf, "…");
+ if (!enc_utf8)
+ {
+ vimconv_T vc;
+
+ vc.vc_type = CONV_NONE;
+ convert_setup(&vc, (char_u *)"utf-8", p_enc);
+ if (vc.vc_type != CONV_NONE)
+ {
+ cp = string_convert(&vc, buf, NULL);
+ if (cp == NULL)
+ {
+ // when conversion fails use '>'
+ cp = buf;
+ STRCPY(buf, ">");
+ }
+ convert_setup(&vc, NULL, NULL);
+ }
+ }
+
+ lp -= (*mb_ptr2cells)(cp) - 1;
lp -= (*mb_head_off)(l, lp);
- STRCPY(lp, "…");
+ STRCPY(lp, cp);
n_used = lp - l + 3 - before - padding;
+ if (cp != buf)
+ vim_free(cp);
}
else
// change last character to '>'
call StopVimInTerminal(buf)
endfunc
+func Test_props_with_text_after_truncated_and_ambiwidth_is_double()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ set ambiwidth=double
+ call setline(1, ['one two three four five six seven'])
+ call prop_type_add('afterprop', #{highlight: 'Search'})
+ call prop_add(1, 0, #{type: 'afterprop', text: ' ONE and TWO and THREE and FOUR and FIVE'})
+
+ call setline(2, ['one two three four five six seven'])
+ call prop_add(2, 0, #{type: 'afterprop', text: ' one AND two AND three AND four AND five', text_align: 'right'})
+
+ call setline(3, ['one two three four five six seven'])
+ call prop_add(3, 0, #{type: 'afterprop', text: ' one AND two AND three AND four AND five lets wrap after some more text', text_align: 'below'})
+
+ call setline(4, ['cursor here'])
+ normal 4Gfh
+ END
+ call writefile(lines, 'XscriptPropsWithTextAfterTrunc-and-ambiwidth-is-double', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropsWithTextAfterTrunc-and-ambiwidth-is-double', #{rows: 9, cols: 60})
+ call VerifyScreenDump(buf, 'Test_prop_with_text_after_trunc_ambiw_d_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+
+func Test_props_with_text_after_truncated_not_utf8()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ set enc=cp932 tenc=utf-8
+ call setline(1, ['one two three four five six seven'])
+ call prop_type_add('afterprop', #{highlight: 'Search'})
+ call prop_add(1, 0, #{type: 'afterprop', text: ' ONE and TWO and THREE and FOUR and FIVE'})
+
+ call setline(2, ['one two three four five six seven'])
+ call prop_add(2, 0, #{type: 'afterprop', text: ' one AND two AND three AND four AND five', text_align: 'right'})
+
+ call setline(3, ['one two three four five six seven'])
+ call prop_add(3, 0, #{type: 'afterprop', text: ' one AND two AND three AND four AND five lets wrap after some more text', text_align: 'below'})
+
+ call setline(4, ['cursor here'])
+ normal 4Gfh
+ END
+ call writefile(lines, 'XscriptPropsWithTextAfterTrunc-enc-is-not-utf8', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropsWithTextAfterTrunc-enc-is-not-utf8', #{rows: 9, cols: 60})
+ call VerifyScreenDump(buf, 'Test_prop_with_text_after_trunc_not_utf8', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_props_with_text_empty_line()
CheckRunVimInTerminal