patch 9.2.0040: completion: preinsert wrong with register completion
Commit:
https://github.com/vim/vim/commit/3684ad83d16514c98ef379f76b55815db43bed8b
Author: Girish Palya <[email protected]>
Date: Sat Feb 21 10:56:26 2026 +0000
patch 9.2.0040: completion: preinsert wrong with register completion
Problem: completion: preinsert wrong with register completion
Solution: Remove preinserted text during register content insertion
(Girish Palya).
fixes: #19329
closes: #19474
Signed-off-by: Girish Palya <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/register.c b/src/register.c
index 2cc840dd5..1f1739160 100644
--- a/src/register.c
+++ b/src/register.c
@@ -1616,6 +1616,9 @@ do_put(
(void)may_get_selection(regname);
#endif
+ // Remove any preinserted text (issue #19329)
+ if (ins_compl_preinsert_effect())
+ ins_compl_delete();
curbuf->b_op_start = curwin->w_cursor; // default for '[ mark
curbuf->b_op_end = curwin->w_cursor; // default for '] mark
diff --git a/src/testdir/test_ins_complete.vim
b/src/testdir/test_ins_complete.vim
index 7e92bac69..2796379c9 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -6265,4 +6265,26 @@ func Test_autocomplete_preinsert_null_leader()
delfunc GetState
endfunc
+" Issue #19329: When register contents are inserted, remove preinserted text
+func Test_ins_register_preinsert_autocomplete()
+ func TestOmni(findstart, base)
+ if a:findstart
+ return col(".") - 1
+ endif
+ return ["foo", "foobar"]
+ endfunc
+
+ call test_override("char_avail", 1)
+ new
+ set omnifunc=TestOmni complete^=o
+ set completeopt=preinsert autocomplete
+
+ call feedkeys("ifoo \<C-R>\<C-P>=\"xyz\"\<CR>\<Esc>", 'tx')
+ call assert_equal("foo xyz", getline('.'))
+ bw!
+ set omnifunc& complete& completeopt& autocomplete&
+ call test_override("char_avail", 0)
+ delfunc TestOmni
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/src/version.c b/src/version.c
index 336ac8894..ea286f11b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 40,
/**/
39,
/**/
--
--
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].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vtqZL-00673I-En%40256bit.org.