Patch 8.2.3348
Problem: line2byte() returns wrong value after adding textprop. (Yuto
Kimura)
Solution: Reduce the length by the size of the text property. (closes #8759)
Files: src/memline.c, src/testdir/test_textprop.vim
*** ../vim-8.2.3347/src/memline.c 2021-07-29 20:37:45.652199179 +0200
--- src/memline.c 2021-08-15 14:26:01.318638705 +0200
***************
*** 3977,3982 ****
--- 3977,3985 ----
*/
if ((int)dp->db_free >= extra)
{
+ #ifdef FEAT_BYTEOFF
+ int old_prop_len = 0;
+ #endif
// if the length changes and there are following lines
count = buf->b_ml.ml_locked_high - buf->b_ml.ml_locked_low + 1;
if (extra != 0 && idx < count - 1)
***************
*** 3995,4007 ****
// adjust free space
dp->db_free -= extra;
dp->db_txt_start -= extra;
// copy new line into the data block
mch_memmove(old_line - extra, new_line, (size_t)new_len);
buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS);
#ifdef FEAT_BYTEOFF
// The else case is already covered by the insert and delete
! ml_updatechunk(buf, lnum, (long)extra, ML_CHNK_UPDLINE);
#endif
}
else
--- 3998,4021 ----
// adjust free space
dp->db_free -= extra;
dp->db_txt_start -= extra;
+ #ifdef FEAT_BYTEOFF
+ if (buf->b_has_textprop)
+ old_prop_len = old_len - STRLEN(new_line) - 1;
+ #endif
// copy new line into the data block
mch_memmove(old_line - extra, new_line, (size_t)new_len);
buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS);
#ifdef FEAT_BYTEOFF
// The else case is already covered by the insert and delete
! if (buf->b_has_textprop)
! {
! // Do not count the size of any text properties.
! extra += old_prop_len;
! extra -= new_len - STRLEN(new_line) - 1;
! }
! if (extra != 0)
! ml_updatechunk(buf, lnum, (long)extra, ML_CHNK_UPDLINE);
#endif
}
else
***************
*** 5595,5601 ****
else
#endif
{
! if (idx == 0)// first line in block, text at the end
text_end = dp->db_txt_end;
else
text_end = ((dp->db_index[idx - 1]) & DB_INDEX_MASK);
--- 5609,5615 ----
else
#endif
{
! if (idx == 0) // first line in block, text at the end
text_end = dp->db_txt_end;
else
text_end = ((dp->db_index[idx - 1]) & DB_INDEX_MASK);
***************
*** 5734,5740 ****
return 1; // Not a "find offset" and offset 0 _must_ be in line 1
/*
* Find the last chunk before the one containing our line. Last chunk is
! * special because it will never qualify
*/
curline = 1;
curix = size = 0;
--- 5748,5754 ----
return 1; // Not a "find offset" and offset 0 _must_ be in line 1
/*
* Find the last chunk before the one containing our line. Last chunk is
! * special because it will never qualify.
*/
curline = 1;
curix = size = 0;
*** ../vim-8.2.3347/src/testdir/test_textprop.vim 2021-08-01
21:30:08.893199555 +0200
--- src/testdir/test_textprop.vim 2021-08-15 14:22:36.435259206 +0200
***************
*** 809,816 ****
--- 809,826 ----
call assert_equal(19, line2byte(3))
call prop_add(1, 1, {'end_col': 3, 'type': 'comment'})
call assert_equal(19, line2byte(3))
+ bwipe!
+ new
+ call setline(1, range(500))
+ call assert_equal(1491, line2byte(401))
+ call prop_add(2, 1, {'type': 'comment'})
+ call prop_add(222, 1, {'type': 'comment'})
+ call assert_equal(1491, line2byte(401))
+ call prop_remove({'type': 'comment'})
+ call assert_equal(1491, line2byte(401))
bwipe!
+
call prop_type_delete('comment')
endfunc
*** ../vim-8.2.3347/src/version.c 2021-08-15 13:49:38.130905563 +0200
--- src/version.c 2021-08-15 14:21:20.243495612 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3348,
/**/
--
BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One.
ANOTHER MONK: And St. Attila raised his hand grenade up on high saying "O
Lord bless this thy hand grenade that with it thou mayest
blow thine enemies to tiny bits, in thy mercy. "and the Lord
did grin and people did feast upon the lambs and sloths and
carp and anchovies and orang-utans and breakfast cereals and
fruit bats and...
BROTHER MAYNARD: Skip a bit brother ...
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202108151232.17FCWEIU3990256%40masaka.moolenaar.net.