diff src/ex_getln.c @ 33585:e628d7f03758 v9.0.2037

patch 9.0.2037: A few remaining cmdline completion issues with C-E/Y Commit: https://github.com/vim/vim/commit/209ec90b9b9bd948d76511c9cd2b17f47a97afe6 Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Tue Oct 17 10:56:25 2023 +0200 patch 9.0.2037: A few remaining cmdline completion issues with C-E/Y Problem: A few remaining cmdline completion issues with C-E/Y Solution: Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not used at the end Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not used at the end A few places in the cmdline completion code only works properly when the user hits Tab (or 'wildchar') at the end of the cmdline, even though it's supposed to work even in the middle of the line. For fuzzy search, `:e ++ff`, and `:set hl=`, fix completion code to make sure to use `xp_pattern_len` instead of assuming the entire `xp_pattern` is the search pattern (since it contains texts after the cursor). Fix Ctrl-E / Ctrl-Y to not jump to the end when canceling/accepting a wildmenu completion. Also, make them work even when not using `set wildoptions+=pum` as there is no drawback to doing so. (Related issue where this was brought up: #13331) closes: #13362 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Tue, 17 Oct 2023 11:00:03 +0200
parents 403d57b06231
children ca0229869b38
line wrap: on
line diff
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1599,7 +1599,7 @@ getcmdline_int(
     cmdline_info_T save_ccline;
     int		did_save_ccline = FALSE;
     int		cmdline_type;
-    int		wild_type;
+    int		wild_type = 0;
 
     // one recursion level deeper
     ++depth;
@@ -1878,7 +1878,7 @@ getcmdline_int(
 	    c = wildmenu_translate_key(&ccline, c, &xpc, did_wild_list);
 
 	int key_is_wc = (c == p_wc && KeyTyped) || c == p_wcm;
-	if (cmdline_pum_active() && !key_is_wc)
+	if ((cmdline_pum_active() || did_wild_list) && !key_is_wc)
 	{
 	    // Ctrl-Y: Accept the current selection and close the popup menu.
 	    // Ctrl-E: cancel the cmdline popup menu and return the original
@@ -1889,7 +1889,6 @@ getcmdline_int(
 		if (nextwild(&xpc, wild_type, WILD_NO_BEEP,
 							firstc != '@') == FAIL)
 		    break;
-		c = Ctrl_E;
 	    }
 	}
 
@@ -2016,6 +2015,14 @@ getcmdline_int(
 
 	do_abbr = TRUE;		// default: check for abbreviation
 
+	// If already used to cancel/accept wildmenu, don't process the key
+	// further.
+	if (wild_type == WILD_CANCEL || wild_type == WILD_APPLY)
+	{
+	    wild_type = 0;
+	    goto cmdline_not_changed;
+	}
+
 	/*
 	 * Big switch for a typed command line character.
 	 */