summaryrefslogtreecommitdiffstats
path: root/src/drawline.c
diff options
context:
space:
mode:
authorh-east <h.east.727@gmail.com>2023-04-17 21:44:57 +0100
committerBram Moolenaar <Bram@vim.org>2023-04-17 21:44:57 +0100
commit4c42c7eef43ff0f58fa574f7a900c8a3313f372e (patch)
tree5ee60a73f7f90435130816f1fc91196deb336932 /src/drawline.c
parent42994bf678f46dc9ca66e49f512261da8864fff6 (diff)
patch 9.0.1463: virtual text truncation only works with Unicode 'encoding'v9.0.1463
Problem: Virtual text truncation only works with Unicode 'encoding'. Solution: Convert the ellipsis character to 'encoding' if needed. (Hirohito Higashi, closes #12233)
Diffstat (limited to 'src/drawline.c')
-rw-r--r--src/drawline.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/drawline.c b/src/drawline.c
index 5c647507d8..c7510a65a2 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -739,10 +739,37 @@ text_prop_position(
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 '>'