commit dd77a0062108d6ecfc00bbc50b0d6d738df0b89d parent 6680002169a8cc505186e81acc161bec40658d73 Author: zeertzjq <zeertzjq@outlook.com> Date: Wed, 24 Aug 2022 21:46:06 +0800 vim-patch:9.0.0102: reading past end of line with insert mode completion Problem: Reading past end of line with insert mode completion. Solution: Check text length. https://github.com/vim/vim/commit/a6f9e300161f4cb54713da22f65b261595e8e614 Diffstat:
| M | src/nvim/insexpand.c | | | 2 | +- |
| M | src/nvim/testdir/test_ins_complete.vim | | | 8 | ++++++++ |
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c @@ -2813,7 +2813,7 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p } else { char_u *tmp_ptr = ptr; - if (compl_cont_status & CONT_ADDING) { + if (compl_cont_status & CONT_ADDING && compl_length <= (int)STRLEN(tmp_ptr)) { tmp_ptr += compl_length; // Skip if already inside a word. if (vim_iswordp(tmp_ptr)) { diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim @@ -986,5 +986,13 @@ func Test_ins_complete_add() bwipe! endfunc +func Test_ins_complete_end_of_line() + " this was reading past the end of the line + new + norm 8oý + sil! norm o + + bwipe! +endfunc " vim: shiftwidth=2 sts=2 expandtab