diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-02-01 07:49:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-01 07:49:05 +0800 |
commit | 9cc060218b66c600f7f50ecbec5ba6f1b3a9da82 (patch) | |
tree | 21f4329fd9c81419555dbcb56a525f1fe077c4f6 | |
parent | e71d2c817d1a2475551f58a98e411f6b39a5be3f (diff) | |
download | rneovim-9cc060218b66c600f7f50ecbec5ba6f1b3a9da82.tar.gz rneovim-9cc060218b66c600f7f50ecbec5ba6f1b3a9da82.tar.bz2 rneovim-9cc060218b66c600f7f50ecbec5ba6f1b3a9da82.zip |
vim-patch:9.1.1059: completion: input text deleted with preinsert when adding leader (#32276)
Problem: completion: input text deleted with preinsert when adding leader
Solution: remove compl_length and check the ptr for being equal
to pattern when preinsert is active (glepnir)
closes: vim/vim#16545
https://github.com/vim/vim/commit/bfb4eea7869b0118221cd145a774d74191ce6130
Co-authored-by: glepnir <glephunter@gmail.com>
-rw-r--r-- | src/nvim/insexpand.c | 5 | ||||
-rw-r--r-- | test/old/testdir/test_ins_complete.vim | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 01029ddda2..44e72b2b01 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -3469,7 +3469,8 @@ static int get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_ int len; char *ptr = ins_compl_get_next_word_or_line(st->ins_buf, st->cur_match_pos, &len, &cont_s_ipos); - if (ptr == NULL) { + if (ptr == NULL + || (ins_compl_has_preinsert() && strcmp(ptr, compl_pattern.data) == 0)) { continue; } if (ins_compl_add_infercase(ptr, len, p_ic, @@ -3728,7 +3729,7 @@ void ins_compl_delete(bool new_leader) int col = compl_col + (compl_status_adding() ? compl_length : orig_col); bool has_preinsert = ins_compl_preinsert_effect(); if (has_preinsert) { - col = compl_col + (int)ins_compl_leader_len() - compl_length; + col += (int)ins_compl_leader_len(); curwin->w_cursor.col = compl_ins_end_col; } diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index 64a0ee3124..f276d1e719 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -3051,6 +3051,10 @@ function Test_completeopt_preinsert() call assert_equal("hello hero", getline('.')) call assert_equal(2, col('.')) + call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>er", 'tx') + call assert_equal("hero", getline('.')) + call assert_equal(3, col('.')) + " can not work with fuzzy set cot+=fuzzy call feedkeys("S\<C-X>\<C-O>", 'tx') |