Hi Bram and Vim developers,
How to reproduce:
- Run vanilla Vim with some setting.
$ vim -Nu NONE +"set bs=indent,eof"
- set buffer lines and cursor goto first line.
:call setline(1, "aaa", "aaa12345", "aaaabcdef")
gg
- Start keyword local completion and Back at original.
A<C-X><C-N><C-P>
- Type some <BS>.
<BS><BS><BS>
Expected result:
- The first line of buffer is `aaa`.
Actual result:
- - The first line of buffer is `a`. Current Vim does not respect 'bs' option
in ins-completion mode.
I wrote a patch. Of course, it has a test.
Please check it.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/edit.c b/src/edit.c
index 1164e20..b94e936 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -3470,7 +3470,9 @@ ins_compl_bs(void)
* allow the word to be deleted, we won't match everything. */
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
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index efbb918..f4ce064 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -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