To: vim_dev@googlegroups.com Subject: Patch 8.0.1731 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1731 Problem: Characters deleted on completion. (Adrià Farrés) Solution: Also check the last item for the ORIGINAL_TEXT flag. (Christian Brabandt, closes #1645) Files: src/edit.c, src/testdir/test_popup.vim *** ../vim-8.0.1730/src/edit.c 2018-03-06 12:10:43.693795133 +0100 --- src/edit.c 2018-04-17 22:06:40.619544998 +0200 *************** *** 3656,3662 **** { char_u *p; ! /* Replace the original text entry. */ if (compl_first_match->cp_flags & ORIGINAL_TEXT) /* safety check */ { p = vim_strsave(str); --- 3656,3664 ---- { char_u *p; ! /* 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,3671 **** --- 3668,3683 ---- 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; + } + } } /* *** ../vim-8.0.1730/src/testdir/test_popup.vim 2018-03-06 13:22:42.815870215 +0100 --- src/testdir/test_popup.vim 2018-04-17 22:04:43.128367641 +0200 *************** *** 814,818 **** --- 814,827 ---- 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\". repeat("\", 3). "rt\", 'tx') + call assert_equal(expected, getline(1,'$')) + bwipe! + endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.0.1730/src/version.c 2018-04-17 22:02:17.589386346 +0200 --- src/version.c 2018-04-17 22:08:22.734829865 +0200 *************** *** 764,765 **** --- 764,767 ---- { /* Add new patch number below this line */ + /**/ + 1731, /**/ -- hundred-and-one symptoms of being an internet addict: 210. When you get a divorce, you don't care about who gets the children, but discuss endlessly who can use the email address. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///