aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fold.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-13 15:00:43 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-03-14 13:09:54 +0800
commit090d1fd0b86897d2f5a80a600becf1525398ef30 (patch)
tree94b10da1cf7d680654d6b597dae2c5bd0686b0be /src/nvim/fold.c
parent3502aa63f0f4ea8d8982aea81a819424e71029bc (diff)
downloadrneovim-090d1fd0b86897d2f5a80a600becf1525398ef30.tar.gz
rneovim-090d1fd0b86897d2f5a80a600becf1525398ef30.tar.bz2
rneovim-090d1fd0b86897d2f5a80a600becf1525398ef30.zip
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 https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b
Diffstat (limited to 'src/nvim/fold.c')
-rw-r--r--src/nvim/fold.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 15aba432c4..e70a05ed9a 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1017,8 +1017,7 @@ void foldAdjustVisual(void)
return;
}
- char *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--;
}
@@ -1605,7 +1604,7 @@ static void foldAddMarker(buf_T *buf, pos_T pos, const char *marker, size_t mark
// Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end
char *line = ml_get_buf(buf, lnum);
- size_t line_len = strlen(line);
+ size_t line_len = (size_t)ml_get_buf_len(buf, lnum);
size_t added = 0;
if (u_save(lnum - 1, lnum + 1) != OK) {
@@ -1686,7 +1685,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char *marker, size_t marker
}
if (u_save(lnum - 1, lnum + 1) == OK) {
// Make new line: text-before-marker + text-after-marker
- char *newline = xmalloc(strlen(line) - len + 1);
+ char *newline = xmalloc((size_t)ml_get_buf_len(buf, lnum) - len + 1);
assert(p >= line);
memcpy(newline, line, (size_t)(p - line));
STRCPY(newline + (p - line), p + len);