mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Problem: More code can use ml_get_buf_len() instead of STRLEN().
Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not
set ml_line_textlen in ml_replace_len() if "has_props" is set,
because "len_arg" also includes the size of text properties in
that case. (zeertzjq)
closes: vim/vim#14183
94b7c3233e
This commit is contained in:
@@ -1840,6 +1840,12 @@ colnr_T ml_get_len(linenr_T lnum)
|
||||
return ml_get_buf_len(curbuf, lnum);
|
||||
}
|
||||
|
||||
/// @return length (excluding the NUL) of the text after position "pos".
|
||||
colnr_T ml_get_pos_len(pos_T *pos)
|
||||
{
|
||||
return ml_get_buf_len(curbuf, curwin->w_cursor.lnum) - pos->col;
|
||||
}
|
||||
|
||||
/// @return length (excluding the NUL) of the given line in the given buffer.
|
||||
colnr_T ml_get_buf_len(buf_T *buf, linenr_T lnum)
|
||||
{
|
||||
@@ -4133,7 +4139,7 @@ int dec(pos_T *lp)
|
||||
if (lp->col == MAXCOL) {
|
||||
// past end of line
|
||||
char *p = ml_get(lp->lnum);
|
||||
lp->col = (colnr_T)strlen(p);
|
||||
lp->col = ml_get_len(lp->lnum);
|
||||
lp->col -= utf_head_off(p, p + lp->col);
|
||||
return 0;
|
||||
}
|
||||
@@ -4149,7 +4155,7 @@ int dec(pos_T *lp)
|
||||
// there is a prior line
|
||||
lp->lnum--;
|
||||
char *p = ml_get(lp->lnum);
|
||||
lp->col = (colnr_T)strlen(p);
|
||||
lp->col = ml_get_len(lp->lnum);
|
||||
lp->col -= utf_head_off(p, p + lp->col);
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user