aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-27 09:17:36 +0800
committerGitHub <noreply@github.com>2025-02-27 09:17:36 +0800
commit189bba7c770e528f71b5ca129f82d5f7a9e113ea (patch)
tree4d720e4aea081ee04ce6d7b0ccba1dbac8239d47 /src/nvim/edit.c
parent3cce6570312830dfab9efd9d521125f0049ad55f (diff)
parentf56d2b3c596218e503cad8f9bdb028bf780577a1 (diff)
downloadrneovim-189bba7c770e528f71b5ca129f82d5f7a9e113ea.tar.gz
rneovim-189bba7c770e528f71b5ca129f82d5f7a9e113ea.tar.bz2
rneovim-189bba7c770e528f71b5ca129f82d5f7a9e113ea.zip
Merge pull request #32649 from zeertzjq/vim-9.1.1151
vim-patch:9.1.{1151,1152}
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index af3471184d..223b0acbc0 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -339,7 +339,7 @@ static void insert_enter(InsertState *s)
if (s->ptr == NULL) {
new_insert_skip = 0;
} else {
- new_insert_skip = (int)strlen(s->ptr);
+ new_insert_skip = (int)get_inserted_len();
xfree(s->ptr);
}
@@ -2342,7 +2342,7 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove)
// Don't do it when "restart_edit" was set and nothing was inserted,
// otherwise CTRL-O w and then <Left> will clear "last_insert".
char *ptr = get_inserted();
- int added = ptr == NULL ? 0 : (int)strlen(ptr) - new_insert_skip;
+ int added = ptr == NULL ? 0 : (int)get_inserted_len() - new_insert_skip;
if (did_restart_edit == 0 || added > 0) {
xfree(last_insert);
last_insert = ptr;
@@ -2772,8 +2772,8 @@ char *get_last_insert_save(void)
if (last_insert == NULL) {
return NULL;
}
- char *s = xstrdup(last_insert + last_insert_skip);
- int len = (int)strlen(s);
+ size_t len = strlen(last_insert + last_insert_skip);
+ char *s = xmemdupz(last_insert + last_insert_skip, len);
if (len > 0 && s[len - 1] == ESC) { // remove trailing ESC
s[len - 1] = NUL;
}