Skip to content

Commit cdd8a5e

Browse files
committed
patch 8.2.3372: line2byte() value wrong when adding a text property
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.
1 parent 5ca5cc6 commit cdd8a5e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/memline.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3251,9 +3251,15 @@ ml_append_int(
32513251
}
32523252

32533253
#ifdef FEAT_BYTEOFF
3254+
# ifdef FEAT_PROP_POPUP
3255+
if (curbuf->b_has_textprop)
3256+
// only use the space needed for the text, ignore properties
3257+
len = (colnr_T)STRLEN(line) + 1;
3258+
# endif
32543259
// The line was inserted below 'lnum'
32553260
ml_updatechunk(buf, lnum + 1, (long)len, ML_CHNK_ADDLINE);
32563261
#endif
3262+
32573263
#ifdef FEAT_NETBEANS_INTG
32583264
if (netbeans_active())
32593265
{
@@ -3752,7 +3758,11 @@ ml_delete_int(buf_T *buf, linenr_T lnum, int flags)
37523758
}
37533759

37543760
#ifdef FEAT_BYTEOFF
3755-
ml_updatechunk(buf, lnum, line_size, ML_CHNK_DELLINE);
3761+
ml_updatechunk(buf, lnum, line_size
3762+
# ifdef FEAT_PROP_POPUP
3763+
- textprop_save_len
3764+
# endif
3765+
, ML_CHNK_DELLINE);
37563766
#endif
37573767
ret = OK;
37583768

src/testdir/test_textprop.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,15 @@ func Test_prop_line2byte()
857857
call assert_equal(1491, line2byte(401))
858858
bwipe!
859859

860+
new
861+
call setline(1, range(520))
862+
call assert_equal(1491, line2byte(401))
863+
call prop_add(2, 1, {'type': 'comment'})
864+
call assert_equal(1491, line2byte(401))
865+
2delete
866+
call assert_equal(1489, line2byte(400))
867+
bwipe!
868+
860869
call prop_type_delete('comment')
861870
endfunc
862871

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3372,
758760
/**/
759761
3371,
760762
/**/

0 commit comments

Comments
 (0)