]> granicus.if.org Git - vim/commitdiff
patch 9.0.0102: reading past end of line with insert mode completion v9.0.0102
authorBram Moolenaar <Bram@vim.org>
Thu, 28 Jul 2022 20:51:37 +0000 (21:51 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 28 Jul 2022 20:51:37 +0000 (21:51 +0100)
Problem:    Reading past end of line with insert mode completion.
Solution:   Check text length.

src/insexpand.c
src/testdir/test_ins_complete.vim
src/version.c

index 7339ce9c6e3a5645a97f7714b35676b2a9f6da0e..fc3eff071341a5dfc903ea90d1a6ee739f398b9f 100644 (file)
@@ -3501,7 +3501,7 @@ ins_comp_get_next_word_or_line(
     {
        char_u  *tmp_ptr = ptr;
 
-       if (compl_status_adding())
+       if (compl_status_adding() && compl_length <= (int)STRLEN(tmp_ptr))
        {
            tmp_ptr += compl_length;
            // Skip if already inside a word.
index 35c5785d3a099ec0ff3be1ac8bcae024e5301431..2b0a2947a0e8c950d0b5fea522ec9eaa6a795902 100644 (file)
@@ -2142,5 +2142,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\80ý 
+  sil! norm o\10\18\10\18\10
+
+  bwipe!
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index 1241e98b08b0f4e2aa899a00a9db9095259d0e00..ce6caa5092ef3bc56e14b50cde83143da3fbe315 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    102,
 /**/
     101,
 /**/