0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

patch 8.1.0643: computing byte offset wrong

Problem:    Computing byte offset wrong. (Bjorn Linse)
Solution:   Use the right variable for array index.
This commit is contained in:
Bram Moolenaar 2018-12-26 23:42:10 +01:00
parent e6fdf79980
commit 00b1e04165
3 changed files with 6 additions and 4 deletions

View File

@ -5380,7 +5380,7 @@ ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp)
// lengths. // lengths.
len = 0; len = 0;
for (i = start_idx; i <= idx; ++i) 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 else
#endif #endif

View File

@ -229,11 +229,11 @@ endfunc
func Test_prop_byteoff() func Test_prop_byteoff()
call prop_type_add('comment', {'highlight': 'Directory'}) call prop_type_add('comment', {'highlight': 'Directory'})
new new
call setline(1, ['line1', 'line2', '']) call setline(1, ['line1', 'second line', ''])
set ff=unix 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 prop_add(1, 1, {'end_col': 3, 'type': 'comment'})
call assert_equal(13, line2byte(3)) call assert_equal(19, line2byte(3))
bwipe! bwipe!
call prop_type_delete('comment') call prop_type_delete('comment')

View File

@ -799,6 +799,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
643,
/**/ /**/
642, 642,
/**/ /**/