File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -3656,7 +3656,9 @@ ins_compl_set_original_text(char_u *str)
36563656{
36573657 char_u * p ;
36583658
3659- /* Replace the original text entry. */
3659+ /* Replace the original text entry.
3660+ * The ORIGINAL_TEXT flag is either at the first item or might possibly be
3661+ * at the last item for backward completion */
36603662 if (compl_first_match -> cp_flags & ORIGINAL_TEXT ) /* safety check */
36613663 {
36623664 p = vim_strsave (str );
@@ -3666,6 +3668,16 @@ ins_compl_set_original_text(char_u *str)
36663668 compl_first_match -> cp_str = p ;
36673669 }
36683670 }
3671+ else if (compl_first_match -> cp_prev != NULL
3672+ && (compl_first_match -> cp_prev -> cp_flags & ORIGINAL_TEXT ))
3673+ {
3674+ p = vim_strsave (str );
3675+ if (p != NULL )
3676+ {
3677+ vim_free (compl_first_match -> cp_prev -> cp_str );
3678+ compl_first_match -> cp_prev -> cp_str = p ;
3679+ }
3680+ }
36693681}
36703682
36713683/*
Original file line number Diff line number Diff line change @@ -814,5 +814,14 @@ func Test_popup_command()
814814 call delete (' Xtest' )
815815endfunc
816816
817+ func Test_popup_complete_backwards ()
818+ new
819+ call setline (1 , [' Post' , ' Port' , ' Po' ])
820+ let expected= [' Post' , ' Port' , ' Port' ]
821+ call cursor (3 ,2 )
822+ call feedkeys (" A\<C-X> " . repeat (" \<C-P> " , 3 ). " rt\<cr> " , ' tx' )
823+ call assert_equal (expected, getline (1 ,' $' ))
824+ bwipe!
825+ endfunc
817826
818827" vim: shiftwidth = 2 sts = 2 expandtab
Original file line number Diff line number Diff line change @@ -762,6 +762,8 @@ static char *(features[]) =
762762
763763static int included_patches [] =
764764{ /* Add new patch number below this line */
765+ /**/
766+ 1731 ,
765767/**/
766768 1730 ,
767769/**/
You can’t perform that action at this time.
0 commit comments