diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-12 21:50:32 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-03-12 21:50:32 +0100 |
commit | 94b7c3233ef534acc669b3083ed1fe59cf3a090b (patch) | |
tree | b7d882e3b2cf90034e730023c01214b7b17294af /src/fold.c | |
parent | 5cac1a9bee0798d70a7fd80363a1f697759638e8 (diff) |
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()v9.1.0172
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>
Diffstat (limited to 'src/fold.c')
-rw-r--r-- | src/fold.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/fold.c b/src/fold.c index 5c41ed1b05..420bcf1b88 100644 --- a/src/fold.c +++ b/src/fold.c @@ -1061,7 +1061,6 @@ find_wl_entry(win_T *win, linenr_T lnum) foldAdjustVisual(void) { pos_T *start, *end; - char_u *ptr; if (!VIsual_active || !hasAnyFolding(curwin)) return; @@ -1082,8 +1081,7 @@ foldAdjustVisual(void) 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 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen) // 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 @@ foldDelMarker(linenr_T lnum, char_u *marker, int markerlen) 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); |