diff options
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 0983d025e5..c551ec2726 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1955,7 +1955,7 @@ static void insert_special(int c, int allow_modmask, int ctrlv) allow_modmask = true; } if (IS_SPECIAL(c) || (mod_mask && allow_modmask)) { - char *p = (char *)get_special_key_name(c, mod_mask); + char *p = get_special_key_name(c, mod_mask); int len = (int)strlen(p); c = (uint8_t)p[len - 1]; if (len > 2) { @@ -2294,11 +2294,11 @@ 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". ptr = get_inserted(); - if (did_restart_edit == 0 || (ptr != NULL - && (int)strlen(ptr) > new_insert_skip)) { + int added = ptr == NULL ? 0 : (int)strlen(ptr) - new_insert_skip; + if (did_restart_edit == 0 || added > 0) { xfree(last_insert); last_insert = ptr; - last_insert_skip = new_insert_skip; + last_insert_skip = added < 0 ? 0 : new_insert_skip; } else { xfree(ptr); } |