patch 9.1.1160: Ctrl-Y does not work well with "preinsert" when completing items
Problem: The 'preinsert' feature requires Ctrl-Y to confirm insertion,
but Ctrl-Y only works when the popup menu (pum) is displayed.
Without enforcing this dependency, it could lead to confusing
behavior or non-functional features.
Solution: Modify ins_compl_has_preinsert() to check for both 'menu' and
'menuone' flags when 'preinsert' is set. Update documentation
to clarify this requirement. This avoids adding complex
conditional behaviors. (glepnir)
fixes: #16728
closes: #16753
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/insexpand.c b/src/insexpand.c
index edc4265..8a6f8af 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -1985,12 +1985,15 @@
}
/*
- * Return TRUE when preinsert is set otherwise FALSE.
+ * Return TRUE when preinsert is set AND both 'menu' and 'menuone' flags
+ * are also set, otherwise return FALSE.
*/
static int
ins_compl_has_preinsert(void)
{
- return (get_cot_flags() & (COT_PREINSERT | COT_FUZZY)) == COT_PREINSERT;
+ int cur_cot_flags = get_cot_flags();
+ return (cur_cot_flags & (COT_PREINSERT | COT_FUZZY | COT_MENU | COT_MENUONE))
+ == (COT_PREINSERT | COT_MENU | COT_MENUONE);
}
/*