]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.0.1731: characters deleted on completion v8.0.1731
authorBram Moolenaar <Bram@vim.org>
Tue, 17 Apr 2018 20:14:32 +0000 (22:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 Apr 2018 20:14:32 +0000 (22:14 +0200)
Problem:    Characters deleted on completion. (Adrià Farrés)
Solution:   Also check the last item for the ORIGINAL_TEXT flag. (Christian
            Brabandt, closes #1645)

src/edit.c
src/testdir/test_popup.vim
src/version.c

index 21941cb3d0c68a6fe6464b4ab7a94f78b496ebf0..8746436fbae24f991643fb0a8089b1597d9d6d06 100644 (file)
@@ -3656,7 +3656,9 @@ ins_compl_set_original_text(char_u *str)
 {
     char_u     *p;
 
-    /* Replace the original text entry. */
+    /* Replace the original text entry.
+     * The ORIGINAL_TEXT flag is either at the first item or might possibly be
+     * at the last item for backward completion */
     if (compl_first_match->cp_flags & ORIGINAL_TEXT)   /* safety check */
     {
        p = vim_strsave(str);
@@ -3666,6 +3668,16 @@ ins_compl_set_original_text(char_u *str)
            compl_first_match->cp_str = p;
        }
     }
+    else if (compl_first_match->cp_prev != NULL
+           && (compl_first_match->cp_prev->cp_flags & ORIGINAL_TEXT))
+    {
+       p = vim_strsave(str);
+       if (p != NULL)
+       {
+           vim_free(compl_first_match->cp_prev->cp_str);
+           compl_first_match->cp_prev->cp_str = p;
+       }
+    }
 }
 
 /*
index 8294febe6ac1e61cc44ffc6db1d29361c6644c47..a2e86d70373bc912a5d8beb9f57e2e95ee853cb8 100644 (file)
@@ -814,5 +814,14 @@ func Test_popup_command()
   call delete('Xtest')
 endfunc
 
+func Test_popup_complete_backwards()
+  new
+  call setline(1, ['Post', 'Port', 'Po'])
+  let expected=['Post', 'Port', 'Port']
+  call cursor(3,2)
+  call feedkeys("A\<C-X>". repeat("\<C-P>", 3). "rt\<cr>", 'tx')
+  call assert_equal(expected, getline(1,'$'))
+  bwipe!
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index 8d5c73a771f70c9379d9cf27b79206e6c85eb331..c3add514465535b37b87dc96ae250f20b97e575d 100644 (file)
@@ -762,6 +762,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1731,
 /**/
     1730,
 /**/