patch 8.2.5014: byte offsets are wrong when using text properties

Problem:    Byte offsets are wrong when using text properties.
Solution:   Make sure text properties do not affect the byte counts.
            (Paul Ollis, closes #10474)
This commit is contained in:
Paul Ollis
2022-05-24 21:26:37 +01:00
committed by Bram Moolenaar
parent 78d52883e1
commit 4c3d21acaa
4 changed files with 106 additions and 6 deletions

View File

@ -4004,6 +4004,8 @@ ml_flush_line(buf_T *buf)
{
#if defined(FEAT_BYTEOFF) && defined(FEAT_PROP_POPUP)
int old_prop_len = 0;
if (buf->b_has_textprop)
old_prop_len = old_len - (int)STRLEN(old_line) - 1;
#endif
// if the length changes and there are following lines
count = buf->b_ml.ml_locked_high - buf->b_ml.ml_locked_low + 1;
@ -4023,10 +4025,6 @@ ml_flush_line(buf_T *buf)
// adjust free space
dp->db_free -= extra;
dp->db_txt_start -= extra;
#if defined(FEAT_BYTEOFF) && defined(FEAT_PROP_POPUP)
if (buf->b_has_textprop)
old_prop_len = old_len - (int)STRLEN(new_line) - 1;
#endif
// copy new line into the data block
mch_memmove(old_line - extra, new_line, (size_t)new_len);