diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-13 15:00:43 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-03-14 13:09:54 +0800 |
commit | 090d1fd0b86897d2f5a80a600becf1525398ef30 (patch) | |
tree | 94b10da1cf7d680654d6b597dae2c5bd0686b0be /src/nvim/edit.c | |
parent | 3502aa63f0f4ea8d8982aea81a819424e71029bc (diff) | |
download | rneovim-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/edit.c')
-rw-r--r-- | src/nvim/edit.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 5b62ab4215..df0c075306 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2968,7 +2968,7 @@ static void replace_do_bs(int limit_col) } del_char_after_col(limit_col); if (l_State & VREPLACE_FLAG) { - orig_len = (int)strlen(get_cursor_pos_ptr()); + orig_len = get_cursor_pos_len(); } replace_push(cc); replace_pop_ins(); @@ -2976,7 +2976,7 @@ static void replace_do_bs(int limit_col) if (l_State & VREPLACE_FLAG) { // Get the number of screen cells used by the inserted characters char *p = get_cursor_pos_ptr(); - int ins_len = (int)strlen(p) - orig_len; + int ins_len = get_cursor_pos_len() - orig_len; int vcol = start_vcol; for (int i = 0; i < ins_len; i++) { vcol += win_chartabsize(curwin, p + i, vcol); @@ -3760,7 +3760,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) return false; } Insstart.lnum--; - Insstart.col = (colnr_T)strlen(ml_get(Insstart.lnum)); + Insstart.col = ml_get_len(Insstart.lnum); } // In replace mode: // cc < 0: NL was inserted, delete it @@ -4480,7 +4480,7 @@ bool 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(get_cursor_pos_ptr()); + curwin->w_cursor.col += get_cursor_pos_len(); } AppendToRedobuff(NL_STR); |