From dd77a0062108d6ecfc00bbc50b0d6d738df0b89d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 21:46:06 +0800 Subject: 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 --- src/nvim/insexpand.c | 2 +- src/nvim/testdir/test_ins_complete.vim | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 56f8834b56..d22c1ff980 100644 --- 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 index 9aa3881724..8f7d2cb278 100644 --- 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 -- cgit