Mercurial > vim
diff src/edit.c @ 34540:9e093c96dff6 v9.1.0172
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Commit: https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue Mar 12 21:50:32 2024 +0100
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 12 Mar 2024 22:00:04 +0100 |
parents | 64edf95a833a |
children | c94ef9458309 |
line wrap: on
line diff
--- a/src/edit.c +++ b/src/edit.c @@ -3222,7 +3222,7 @@ replace_do_bs(int limit_col) { // Do not adjust text properties for individual delete and insert // operations, do it afterwards on the resulting text. - len_before = STRLEN(ml_get_curline()); + len_before = ml_get_curline_len(); ++text_prop_frozen; } #endif @@ -3237,14 +3237,14 @@ replace_do_bs(int limit_col) { (void)del_char_after_col(limit_col); if (State & VREPLACE_FLAG) - orig_len = (int)STRLEN(ml_get_cursor()); + orig_len = ml_get_cursor_len(); replace_push(cc); } else { pchar_cursor(cc); if (State & VREPLACE_FLAG) - orig_len = (int)STRLEN(ml_get_cursor()) - 1; + orig_len = ml_get_cursor_len() - 1; } replace_pop_ins(); @@ -3252,7 +3252,7 @@ replace_do_bs(int limit_col) { // Get the number of screen cells used by the inserted characters p = ml_get_cursor(); - ins_len = (int)STRLEN(p) - orig_len; + ins_len = ml_get_cursor_len() - orig_len; vcol = start_vcol; for (i = 0; i < ins_len; ++i) { @@ -3278,7 +3278,7 @@ replace_do_bs(int limit_col) #ifdef FEAT_PROP_POPUP if (curbuf->b_has_textprop) { - size_t len_now = STRLEN(ml_get_curline()); + size_t len_now = ml_get_curline_len(); --text_prop_frozen; adjust_prop_columns(curwin->w_cursor.lnum, curwin->w_cursor.col, @@ -4068,7 +4068,7 @@ ins_bs( (linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL) return FALSE; --Insstart.lnum; - Insstart.col = (colnr_T)STRLEN(ml_get(Insstart.lnum)); + Insstart.col = ml_get_len(Insstart.lnum); } /* * In replace mode: @@ -5174,7 +5174,7 @@ ins_eol(int c) // NL in reverse insert will always start in the end of // current line. if (revins_on) - curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor()); + curwin->w_cursor.col += ml_get_cursor_len(); #endif AppendToRedobuff(NL_STR);