Mercurial > vim
diff src/drawline.c @ 32264:0df66713766e v9.0.1463
patch 9.0.1463: virtual text truncation only works with Unicode 'encoding'
Commit: https://github.com/vim/vim/commit/4c42c7eef43ff0f58fa574f7a900c8a3313f372e
Author: h-east <h.east.727@gmail.com>
Date: Mon Apr 17 21:44:57 2023 +0100
patch 9.0.1463: virtual text truncation only works with Unicode 'encoding'
Problem: Virtual text truncation only works with Unicode 'encoding'.
Solution: Convert the ellipsis character to 'encoding' if needed. (Hirohito
Higashi, closes #12233)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 Apr 2023 23:00:05 +0200 |
parents | fe1550f920d8 |
children | 15352bf5c33e |
line wrap: on
line diff
--- 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 '>'