To: vim_dev@googlegroups.com Subject: Patch 9.0.0567 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0567 Problem: 'completeopt' "longest" is not used for complete(). Solution: Also use "longest" for complete(). (Bjorn Linse, closes #11206) Files: src/insexpand.c, src/testdir/test_ins_complete.vim *** ../vim-9.0.0566/src/insexpand.c 2022-09-04 12:47:15.410692254 +0100 --- src/insexpand.c 2022-09-24 11:13:53.873572020 +0100 *************** *** 153,158 **** --- 153,160 ---- // TRUE: noinsert static int compl_no_select = FALSE; // FALSE: select & insert // TRUE: noselect + static int compl_longest = FALSE; // FALSE: insert full match + // TRUE: insert longest prefix // Selected one of the matches. When FALSE the match was edited or using the // longest common string. *************** *** 1042,1051 **** --- 1044,1056 ---- { compl_no_insert = FALSE; compl_no_select = FALSE; + compl_longest = FALSE; if (strstr((char *)p_cot, "noselect") != NULL) compl_no_select = TRUE; if (strstr((char *)p_cot, "noinsert") != NULL) compl_no_insert = TRUE; + if (strstr((char *)p_cot, "longest") != NULL) + compl_longest = TRUE; } *************** *** 2383,2389 **** if (ctrl_x_mode_not_defined_yet() || (ctrl_x_mode_normal() && !compl_started)) { ! compl_get_longest = (strstr((char *)p_cot, "longest") != NULL); compl_used_match = TRUE; } --- 2388,2394 ---- if (ctrl_x_mode_not_defined_yet() || (ctrl_x_mode_normal() && !compl_started)) { ! compl_get_longest = compl_longest; compl_used_match = TRUE; } *************** *** 2864,2869 **** --- 2869,2875 ---- ins_compl_prep(' '); ins_compl_clear(); ins_compl_free(); + compl_get_longest = compl_longest; compl_direction = FORWARD; if (startcol > curwin->w_cursor.col) *************** *** 2888,2897 **** compl_cont_status = 0; compl_curr_match = compl_first_match; ! if (compl_no_insert || compl_no_select) { ins_complete(K_DOWN, FALSE); ! if (compl_no_select) // Down/Up has no real effect. ins_complete(K_UP, FALSE); } --- 2894,2904 ---- compl_cont_status = 0; compl_curr_match = compl_first_match; ! int no_select = compl_no_select || compl_longest; ! if (compl_no_insert || no_select) { ins_complete(K_DOWN, FALSE); ! if (no_select) // Down/Up has no real effect. ins_complete(K_UP, FALSE); } *** ../vim-9.0.0566/src/testdir/test_ins_complete.vim 2022-09-02 21:55:45.503049444 +0100 --- src/testdir/test_ins_complete.vim 2022-09-24 11:13:53.873572020 +0100 *************** *** 699,704 **** --- 699,724 ---- bw! endfunc + " Test for using complete() with completeopt+=longest + func Test_complete_with_longest() + inoremap call complete(1, ["iaax", "iaay", "iaaz"]) + new + + " default: insert first match + set completeopt& + call setline(1, ['i']) + exe "normal Aa\\" + call assert_equal('iaax', getline(1)) + + " with longest: insert longest prefix + set completeopt+=longest + call setline(1, ['i']) + exe "normal Aa\\" + call assert_equal('iaa', getline(1)) + set completeopt& + endfunc + + " Test for completing words following a completed word in a line func Test_complete_wrapscan() " complete words from another buffer *** ../vim-9.0.0566/src/version.c 2022-09-24 11:04:34.841432904 +0100 --- src/version.c 2022-09-24 11:16:07.432384836 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 567, /**/ -- hundred-and-one symptoms of being an internet addict: 156. You forget your friend's name but not her e-mail address. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///