]> granicus.if.org Git - vim/commitdiff
patch 8.0.0319: insert mode completion does not respect 'backspace' v8.0.0319
authorBram Moolenaar <Bram@vim.org>
Thu, 9 Feb 2017 16:37:03 +0000 (17:37 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 9 Feb 2017 16:37:03 +0000 (17:37 +0100)
Problem:    Insert mode completion does not respect "start" in 'backspace'.
Solution:   Check whether backspace can go before where insert started.
            (Hirohito Higashi)

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

index 1164e2032a5aeb3ea9a2444718c21af88f0f5816..bc8652ba413115320996c275f43f09653989ab84 100644 (file)
@@ -3467,10 +3467,13 @@ ins_compl_bs(void)
     mb_ptr_back(line, p);
 
     /* Stop completion when the whole word was deleted.  For Omni completion
-     * allow the word to be deleted, we won't match everything. */
+     * allow the word to be deleted, we won't match everything.
+     * Respect the 'backspace' option. */
     if ((int)(p - line) - (int)compl_col < 0
            || ((int)(p - line) - (int)compl_col == 0
-               && ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL)
+               && ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL
+           || (!can_bs(BS_START) && (int)(p - line) - (int)compl_col
+                                                       - compl_length < 0))
        return K_BS;
 
     /* Deleted more than what was used to find matches or didn't finish
index efbb9185d2d2578d0a6e662732022b86c02a24a5..f4ce064d7ba5bba0e861d3d6b2abc3650df35f43 100644 (file)
@@ -511,4 +511,24 @@ func Test_completion_clear_candidate_list()
   bw!
 endfunc
 
+func Test_completion_respect_bs_option()
+  new
+  let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"]
+
+  set bs=indent,eol
+  call setline(1, li)
+  1
+  call feedkeys("A\<C-X>\<C-N>\<C-P>\<BS>\<BS>\<BS>\<Esc>", "tx")
+  call assert_equal('aaa', getline(1))
+
+  %d
+  set bs=indent,eol,start
+  call setline(1, li)
+  1
+  call feedkeys("A\<C-X>\<C-N>\<C-P>\<BS>\<BS>\<BS>\<Esc>", "tx")
+  call assert_equal('', getline(1))
+
+  bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 1448e981dee2d2ded5e0d732e3c9c69d055e5581..09680b9bc2afb9186118e2936f7464b7c9208950 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    319,
 /**/
     318,
 /**/