# HG changeset patch # User Bram Moolenaar # Date 1545864304 -3600 # Node ID 27783a6f430b78c057d48bde140db4637ec79f0e # Parent f68426fdd0e648dd9c42e5f1ff79129c18bd7c33 patch 8.1.0643: computing byte offset wrong commit https://github.com/vim/vim/commit/00b1e041654e8a38fb6b81218a037e1dc94e0943 Author: Bram Moolenaar Date: Wed Dec 26 23:42:10 2018 +0100 patch 8.1.0643: computing byte offset wrong Problem: Computing byte offset wrong. (Bjorn Linse) Solution: Use the right variable for array index. diff --git a/src/memline.c b/src/memline.c --- a/src/memline.c +++ b/src/memline.c @@ -5380,7 +5380,7 @@ ml_find_line_or_offset(buf_T *buf, linen // lengths. len = 0; for (i = start_idx; i <= idx; ++i) - len += STRLEN((char_u *)dp + ((dp->db_index[idx]) & DB_INDEX_MASK)) + 1; + len += STRLEN((char_u *)dp + ((dp->db_index[i]) & DB_INDEX_MASK)) + 1; } else #endif diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -229,11 +229,11 @@ endfunc func Test_prop_byteoff() call prop_type_add('comment', {'highlight': 'Directory'}) new - call setline(1, ['line1', 'line2', '']) + call setline(1, ['line1', 'second line', '']) set ff=unix - call assert_equal(13, line2byte(3)) + call assert_equal(19, line2byte(3)) call prop_add(1, 1, {'end_col': 3, 'type': 'comment'}) - call assert_equal(13, line2byte(3)) + call assert_equal(19, line2byte(3)) bwipe! call prop_type_delete('comment') diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -800,6 +800,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 643, +/**/ 642, /**/ 641,