patch 9.1.1127: preinsert text is not cleaned up correctly
Commit:
https://github.com/vim/vim/commit/52fd867f5e8a371653ee4fb6664593c82030f855
Author: glepnir <[email protected]>
Date: Thu Feb 20 22:13:24 2025 +0100
patch 9.1.1127: preinsert text is not cleaned up correctly
Problem: when 'completeopt' is set to preinsert the preinserted text is
not cleared when adding new leader (Yee Cheng Chin)
Solution: add a condition to delete preinsert text in edit function
(glepnir)
closes: #16672
Signed-off-by: glepnir <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/edit.c b/src/edit.c
index 72a82f8fc..8ad5a66e2 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -146,6 +146,7 @@ edit(
#ifdef FEAT_CONCEAL
int cursor_line_was_concealed;
#endif
+ int ins_completion = FALSE;
// Remember whether editing was restarted after CTRL-O.
did_restart_edit = restart_edit;
@@ -636,10 +637,11 @@ edit(
* and the cursor is still in the completed word. Only when there is
* a match, skip this when no matches were found.
*/
- if (ins_compl_active()
- && pum_wanted()
- && curwin->w_cursor.col >= ins_compl_col()
- && ins_compl_has_shown_match())
+ ins_completion = ins_compl_active()
+ && curwin->w_cursor.col >= ins_compl_col()
+ && ins_compl_has_shown_match();
+
+ if (ins_completion && pum_wanted())
{
// BS: Delete one character from "compl_leader".
if ((c == K_BS || c == Ctrl_H)
@@ -697,6 +699,8 @@ edit(
ins_compl_delete();
}
}
+ else if (ins_completion && !pum_wanted() &&
ins_compl_preinsert_effect())
+ ins_compl_delete();
// Prepare for or stop CTRL-X mode. This doesn't do completion, but
// it does fix up the text when finishing completion.
diff --git a/src/testdir/test_ins_complete.vim
b/src/testdir/test_ins_complete.vim
index 4ecf2893d..0b943712b 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -3171,6 +3171,11 @@ function Test_completeopt_preinsert()
call assert_equal("fobar", getline('.'))
call assert_equal(5, col('.'))
+ set cot=preinsert
+ call feedkeys("Sfoo1 foo2\<CR>f\<C-X>\<C-N>bar", 'tx')
+ call assert_equal("fbar", getline('.'))
+ call assert_equal(4, col('.'))
+
bw!
set cot&
set omnifunc&
diff --git a/src/version.c b/src/version.c
index 61e2d6b0a..fad08acae 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1127,
/**/
1126,
/**/
--
--
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/E1tlE7P-003Bjh-L2%40256bit.org.