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: #14183
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
5cac1a9bee
commit
94b7c3233e
@ -455,7 +455,7 @@ internal_format(
|
||||
// Check if cursor is not past the NUL off the line, cindent
|
||||
// may have added or removed indent.
|
||||
curwin->w_cursor.col += startcol;
|
||||
len = (colnr_T)STRLEN(ml_get_curline());
|
||||
len = ml_get_curline_len();
|
||||
if (curwin->w_cursor.col > len)
|
||||
curwin->w_cursor.col = len;
|
||||
}
|
||||
@ -531,9 +531,7 @@ ends_in_white(linenr_T lnum)
|
||||
|
||||
if (*s == NUL)
|
||||
return FALSE;
|
||||
// Don't use STRLEN() inside VIM_ISWHITE(), SAS/C complains: "macro
|
||||
// invocation may call function multiple times".
|
||||
l = STRLEN(s) - 1;
|
||||
l = ml_get_len(lnum) - 1;
|
||||
return VIM_ISWHITE(s[l]);
|
||||
}
|
||||
|
||||
@ -573,7 +571,7 @@ same_leader(
|
||||
return FALSE;
|
||||
if (*p == COM_START)
|
||||
{
|
||||
int line_len = (int)STRLEN(ml_get(lnum));
|
||||
int line_len = ml_get_len(lnum);
|
||||
if (line_len <= leader1_len)
|
||||
return FALSE;
|
||||
if (leader2_flags == NULL || leader2_len == 0)
|
||||
@ -684,7 +682,7 @@ auto_format(
|
||||
// in 'formatoptions' and there is a single character before the cursor.
|
||||
// Otherwise the line would be broken and when typing another non-white
|
||||
// next they are not joined back together.
|
||||
wasatend = (pos.col == (colnr_T)STRLEN(old));
|
||||
wasatend = (pos.col == ml_get_curline_len());
|
||||
if (*old != NUL && !trailblank && wasatend)
|
||||
{
|
||||
dec_cursor();
|
||||
@ -740,7 +738,7 @@ auto_format(
|
||||
if (!wasatend && has_format_option(FO_WHITE_PAR))
|
||||
{
|
||||
new = ml_get_curline();
|
||||
len = (colnr_T)STRLEN(new);
|
||||
len = ml_get_curline_len();
|
||||
if (curwin->w_cursor.col == len)
|
||||
{
|
||||
pnew = vim_strnsave(new, len + 2);
|
||||
@ -1217,7 +1215,7 @@ format_lines(
|
||||
}
|
||||
first_par_line = FALSE;
|
||||
// If the line is getting long, format it next time
|
||||
if (STRLEN(ml_get_curline()) > (size_t)max_len)
|
||||
if (ml_get_curline_len() > max_len)
|
||||
force_format = TRUE;
|
||||
else
|
||||
force_format = FALSE;
|
||||
|
||||
Reference in New Issue
Block a user