Skip to content

Commit 190b04c

Browse files
committed
patch 8.0.0319: insert mode completion does not respect 'backspace'
Problem: Insert mode completion does not respect "start" in 'backspace'. Solution: Check whether backspace can go before where insert started. (Hirohito Higashi)
1 parent a9f8ffb commit 190b04c

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/edit.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,10 +3467,13 @@ ins_compl_bs(void)
34673467
mb_ptr_back(line, p);
34683468

34693469
/* Stop completion when the whole word was deleted. For Omni completion
3470-
* allow the word to be deleted, we won't match everything. */
3470+
* allow the word to be deleted, we won't match everything.
3471+
* Respect the 'backspace' option. */
34713472
if ((int)(p - line) - (int)compl_col < 0
34723473
|| ((int)(p - line) - (int)compl_col == 0
3473-
&& ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL)
3474+
&& ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL
3475+
|| (!can_bs(BS_START) && (int)(p - line) - (int)compl_col
3476+
- compl_length < 0))
34743477
return K_BS;
34753478

34763479
/* Deleted more than what was used to find matches or didn't finish

src/testdir/test_popup.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,24 @@ func Test_completion_clear_candidate_list()
511511
bw!
512512
endfunc
513513

514+
func Test_completion_respect_bs_option()
515+
new
516+
let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"]
517+
518+
set bs=indent,eol
519+
call setline(1, li)
520+
1
521+
call feedkeys("A\<C-X>\<C-N>\<C-P>\<BS>\<BS>\<BS>\<Esc>", "tx")
522+
call assert_equal('aaa', getline(1))
523+
524+
%d
525+
set bs=indent,eol,start
526+
call setline(1, li)
527+
1
528+
call feedkeys("A\<C-X>\<C-N>\<C-P>\<BS>\<BS>\<BS>\<Esc>", "tx")
529+
call assert_equal('', getline(1))
530+
531+
bw!
532+
endfunc
533+
514534
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
319,
767769
/**/
768770
318,
769771
/**/

0 commit comments

Comments
 (0)