diff src/cmdexpand.c @ 31798:5948cc887603 v9.0.1231

patch 9.0.1231: completion of :runtime does not handle {where} argument Commit: https://github.com/vim/vim/commit/3770f4c9cde7b5fcd10b6fa2e665cd0b69450fb2 Author: zeertzjq <zeertzjq@outlook.com> Date: Sun Jan 22 18:38:51 2023 +0000 patch 9.0.1231: completion of :runtime does not handle {where} argument Problem: Completion of :runtime does not handle {where} argument. Solution: Parse the {where} argument. (closes https://github.com/vim/vim/issues/11863)
author Bram Moolenaar <Bram@vim.org>
date Sun, 22 Jan 2023 19:45:04 +0100
parents 18da1d44878a
children c5ff7d053fa1
line wrap: on
line diff
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -2315,8 +2315,7 @@ set_context_by_cmdname(
 	    break;
 
 	case CMD_runtime:
-	    xp->xp_context = EXPAND_RUNTIME;
-	    xp->xp_pattern = arg;
+	    set_context_in_runtime_cmd(xp, arg);
 	    break;
 
 	case CMD_compiler:
@@ -3028,9 +3027,7 @@ ExpandFromContext(
     }
     if (xp->xp_context == EXPAND_RUNTIME)
     {
-	char *directories[] = {"", NULL};
-	return ExpandRTDir(pat, DIP_START + DIP_OPT + DIP_PRNEXT, numMatches,
-							 matches, directories);
+	return expand_runtime_cmd(pat, numMatches, matches);
     }
     if (xp->xp_context == EXPAND_COMPILER)
     {
@@ -3612,13 +3609,15 @@ ExpandUserList(
 /*
  * Expand "file" for all comma-separated directories in "path".
  * Adds the matches to "ga".  Caller must init "ga".
+ * If "dirs" is TRUE only expand directory names.
  */
     void
 globpath(
     char_u	*path,
     char_u	*file,
     garray_T	*ga,
-    int		expand_options)
+    int		expand_options,
+    int		dirs)
 {
     expand_T	xpc;
     char_u	*buf;
@@ -3631,7 +3630,7 @@ globpath(
 	return;
 
     ExpandInit(&xpc);
-    xpc.xp_context = EXPAND_FILES;
+    xpc.xp_context = dirs ? EXPAND_DIRECTORIES : EXPAND_FILES;
 
     // Loop over all entries in {path}.
     while (*path != NUL)
@@ -4038,6 +4037,11 @@ f_getcompletion(typval_T *argvars, typva
 	    xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
 	}
 # endif
+	if (xpc.xp_context == EXPAND_RUNTIME)
+	{
+	    set_context_in_runtime_cmd(&xpc, xpc.xp_pattern);
+	    xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
+	}
     }
 
     if (cmdline_fuzzy_completion_supported(&xpc))