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>
diff --git a/src/fold.c b/src/fold.c
index 5c41ed1..420bcf1 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1061,7 +1061,6 @@
foldAdjustVisual(void)
{
pos_T *start, *end;
- char_u *ptr;
if (!VIsual_active || !hasAnyFolding(curwin))
return;
@@ -1082,8 +1081,7 @@
if (!hasFolding(end->lnum, NULL, &end->lnum))
return;
- ptr = ml_get(end->lnum);
- end->col = (colnr_T)STRLEN(ptr);
+ end->col = ml_get_len(end->lnum);
if (end->col > 0 && *p_sel == 'o')
--end->col;
// prevent cursor from moving on the trail byte
@@ -1799,7 +1797,7 @@
// Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end
line = ml_get(lnum);
- line_len = (int)STRLEN(line);
+ line_len = ml_get_len(lnum);
if (u_save(lnum - 1, lnum + 1) != OK)
return;
@@ -1887,7 +1885,7 @@
if (u_save(lnum - 1, lnum + 1) == OK)
{
// Make new line: text-before-marker + text-after-marker
- newline = alloc(STRLEN(line) - len + 1);
+ newline = alloc(ml_get_len(lnum) - len + 1);
if (newline != NULL)
{
STRNCPY(newline, line, p - line);