Mercurial > vim
comparison src/charset.c @ 29583:32aee589fc9a v9.0.0132
patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Commit: https://github.com/vim/vim/commit/09ff4b54fb86a64390ba9c609853c6410ea6197c
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 1 16:51:02 2022 +0100
patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Problem: Multi-byte characters in virtual text not handled correctly.
Solution: Count screen cells instead of bytes.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 01 Aug 2022 18:00:05 +0200 |
parents | 24f01baa27b2 |
children | 5233acfa06f1 |
comparison
equal
deleted
inserted
replaced
29582:902abc03f8ee | 29583:32aee589fc9a |
---|---|
1095 || (tp->tp_col == MAXCOL && (s[0] == NUL || s[1] == NUL) | 1095 || (tp->tp_col == MAXCOL && (s[0] == NUL || s[1] == NUL) |
1096 && cts->cts_with_trailing))) | 1096 && cts->cts_with_trailing))) |
1097 { | 1097 { |
1098 char_u *p = ((char_u **)wp->w_buffer->b_textprop_text.ga_data)[ | 1098 char_u *p = ((char_u **)wp->w_buffer->b_textprop_text.ga_data)[ |
1099 -tp->tp_id - 1]; | 1099 -tp->tp_id - 1]; |
1100 int len = (int)STRLEN(p); | 1100 int len = vim_strsize(p); |
1101 | 1101 |
1102 // TODO: count screen cells | |
1103 if (tp->tp_col == MAXCOL) | 1102 if (tp->tp_col == MAXCOL) |
1104 { | 1103 { |
1105 // TODO: truncating | 1104 // TODO: truncating |
1106 if (tp->tp_flags & TP_FLAG_ALIGN_BELOW) | 1105 if (tp->tp_flags & TP_FLAG_ALIGN_BELOW) |
1107 len += wp->w_width - (vcol + size) % wp->w_width; | 1106 len += wp->w_width - (vcol + size) % wp->w_width; |
1452 if (end != NULL) | 1451 if (end != NULL) |
1453 *end = vcol + incr - 1; | 1452 *end = vcol + incr - 1; |
1454 if (cursor != NULL) | 1453 if (cursor != NULL) |
1455 { | 1454 { |
1456 #ifdef FEAT_PROP_POPUP | 1455 #ifdef FEAT_PROP_POPUP |
1457 // cursor is after inserted text | 1456 if ((State & MODE_INSERT) == 0) |
1458 vcol += cts.cts_cur_text_width; | 1457 // cursor is after inserted text |
1458 vcol += cts.cts_cur_text_width; | |
1459 #endif | 1459 #endif |
1460 if (*ptr == TAB | 1460 if (*ptr == TAB |
1461 && (State & MODE_NORMAL) | 1461 && (State & MODE_NORMAL) |
1462 && !wp->w_p_list | 1462 && !wp->w_p_list |
1463 && !virtual_active() | 1463 && !virtual_active() |