Skip to content

Commit

Permalink
patch 8.2.3372: line2byte() value wrong when adding a text property
Browse files Browse the repository at this point in the history
Problem:    line2byte() value wrong when adding a text property. (Yuto Kimura)
Solution:   Adjust length for text property. (closes #8772)  Also fix it for
            deleting a line.
  • Loading branch information
brammool committed Aug 25, 2021
1 parent 5ca5cc6 commit cdd8a5e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/memline.c
Original file line number Diff line number Diff line change
Expand Up @@ -3251,9 +3251,15 @@ ml_append_int(
}

#ifdef FEAT_BYTEOFF
# ifdef FEAT_PROP_POPUP
if (curbuf->b_has_textprop)
// only use the space needed for the text, ignore properties
len = (colnr_T)STRLEN(line) + 1;
# endif
// The line was inserted below 'lnum'
ml_updatechunk(buf, lnum + 1, (long)len, ML_CHNK_ADDLINE);
#endif

#ifdef FEAT_NETBEANS_INTG
if (netbeans_active())
{
Expand Down Expand Up @@ -3752,7 +3758,11 @@ ml_delete_int(buf_T *buf, linenr_T lnum, int flags)
}

#ifdef FEAT_BYTEOFF
ml_updatechunk(buf, lnum, line_size, ML_CHNK_DELLINE);
ml_updatechunk(buf, lnum, line_size
# ifdef FEAT_PROP_POPUP
- textprop_save_len
# endif
, ML_CHNK_DELLINE);
#endif
ret = OK;

Expand Down
9 changes: 9 additions & 0 deletions src/testdir/test_textprop.vim
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,15 @@ func Test_prop_line2byte()
call assert_equal(1491, line2byte(401))
bwipe!

new
call setline(1, range(520))
call assert_equal(1491, line2byte(401))
call prop_add(2, 1, {'type': 'comment'})
call assert_equal(1491, line2byte(401))
2delete
call assert_equal(1489, line2byte(400))
bwipe!

call prop_type_delete('comment')
endfunc

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3372,
/**/
3371,
/**/
Expand Down

0 comments on commit cdd8a5e

Please sign in to comment.