diff options
author | Paul Ollis <paul@cleversheep.org> | 2022-05-24 21:26:37 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-24 21:26:37 +0100 |
commit | 4c3d21acaa09d929e6afe10288babe1d0af3de35 (patch) | |
tree | 2dc8dcb057fdeb4ab2bd2398e460a1692a0ac519 /src/textprop.c | |
parent | 78d52883e10d71f23ab72a3d8b9733b00da8c9ad (diff) | |
download | vim-git-4c3d21acaa09d929e6afe10288babe1d0af3de35.tar.gz |
patch 8.2.5014: byte offsets are wrong when using text propertiesv8.2.5014
Problem: Byte offsets are wrong when using text properties.
Solution: Make sure text properties do not affect the byte counts.
(Paul Ollis, closes #10474)
Diffstat (limited to 'src/textprop.c')
-rw-r--r-- | src/textprop.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/textprop.c b/src/textprop.c index 6fc628a27..9d3487fde 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -344,6 +344,10 @@ f_prop_add_list(typval_T *argvars, typval_T *rettv UNUSED) if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL) return; + // This must be done _before_ we start adding properties because property + // changes trigger buffer (memline) reorganisation, which needs this flag + // to be correctly set. + buf->b_has_textprop = TRUE; // this is never reset FOR_ALL_LIST_ITEMS(argvars[1].vval.v_list, li) { if (li->li_tv.v_type != VAR_LIST || li->li_tv.vval.v_list == NULL) @@ -368,7 +372,6 @@ f_prop_add_list(typval_T *argvars, typval_T *rettv UNUSED) return; } - buf->b_has_textprop = TRUE; // this is never reset redraw_buf_later(buf, VALID); } @@ -441,9 +444,13 @@ prop_add_common( if (dict_arg != NULL && get_bufnr_from_arg(dict_arg, &buf) == FAIL) return; + // This must be done _before_ we add the property because property changes + // trigger buffer (memline) reorganisation, which needs this flag to be + // correctly set. + buf->b_has_textprop = TRUE; // this is never reset + prop_add_one(buf, type_name, id, start_lnum, end_lnum, start_col, end_col); - buf->b_has_textprop = TRUE; // this is never reset redraw_buf_later(buf, VALID); } |